decorator-pattern

Mechanism for Dependency Injection to Provide the Most Specific Implementation of a Generic Service Interface

♀尐吖头ヾ 提交于 2019-12-06 02:54:49
问题 I feel like I played buzzword bingo with the title. Here's a concise example of what I'm asking. Let's say I have some inheritance hierarchy for some entities. class BaseEntity { ... } class ChildAEntity : BaseEntity { ... } class GrandChildAEntity : ChildAEntity { ... } class ChildBEntity : BaseEntity { ... } Now let's say I have a generic interface for a service with a method that uses the base class: interface IEntityService<T> where T : BaseEntity { void DoSomething(BaseEntity entity)...

Mechanism for Dependency Injection to Provide the Most Specific Implementation of a Generic Service Interface

跟風遠走 提交于 2019-12-04 05:40:02
I feel like I played buzzword bingo with the title. Here's a concise example of what I'm asking. Let's say I have some inheritance hierarchy for some entities. class BaseEntity { ... } class ChildAEntity : BaseEntity { ... } class GrandChildAEntity : ChildAEntity { ... } class ChildBEntity : BaseEntity { ... } Now let's say I have a generic interface for a service with a method that uses the base class: interface IEntityService<T> where T : BaseEntity { void DoSomething(BaseEntity entity)... } I have some concrete implementations: class BaseEntityService : IEntityService<BaseEntity> { ... }