c# - Castle Windsor - Resolving a generic implementation to a base type -
I used Windsor as a factory to implement the specification on the basis of sub types of XAbstractBase
Trying to use (an abstract message base class in my case).
I have the following code:
Public abstract class XAbstractBase {} Public class YImplementation: XAbstractBase {} Public class ZImplementation: XAbstractBase {} Public Interface ISpecification & lt; T & gt; Where T: XAbstractBase {bool PredicateLogic (); } Public Square DefaultSpecificationImplementation: ISpecification & lt; XAbstractBase & gt; {Public Child PredicateLogic () {Return Truth; }} Public Sector Exclusive Governance Implementation: ISPCification & lt; YIplementation & gt; {Public bool PredicateLogic () {/ * Actual Work *}}
My Component Registration Code looks like this:
Container Based on the AllTypes .FromAssembly (Assembly.GetExecutingAssembly ()). ((ISpecification & gt;)) .WithService.FirstInterface ())
I try to solve ISpecification & lt so it works fine; YImplementation & gt; ; This resolves specific typical implementation implementation
correctly.
However, when I use ISpecification & lt; ZImplementation & gt;
, Windsor throws an exception:
"There is no component to support the service ISPCification" [1] [...] < / Code>
Windsor support resolves general implementation of normal classes if there is no more specific implementation registered?
View the post.
Update
OK, now I see what you're doing wrong ISpecification & lt; ZImplementation & gt; There is no service for
, so it is not surprising that Windsor can not solve it.
This is not exactly Windsor problem.
Comments
Post a Comment