http://stackoverflow.com/questions/1676873/resolving-a-generic-with-a-generic-parameter-in-castle-windsor

On Nov 4, 6:43 pm, Aaron Fischer <[email protected]> wrote:
> I am trying to register a type like IRequestHandler`1
> [GenericTestRequest`1[T]] which will be implemented by
> GenericTestRequestHandler`1[T] but I am currently getting an error
> from Windsor "Castle.MicroKernel.ComponentNotFoundException : No
> component for supporting the service " Is this type of operation
> supported?  Or is it to far removed from the suppored register
> ( Component.For(typeof( IList<>).ImplementedBy( typeof( List<> ) ) )
>
> below is an example of a breaking test.
> //////////////////////////////////////////////////////
> public interface IRequestHandler{}
>
> public interface IRequestHandler<TRequest> : IRequestHandler where
> TRequest : Request{}
>
> public class  GenericTestRequest<T> : Request{}
>
> public class GenericTestRequestHandler<T> :
> RequestHandler<GenericTestRequest<T>>{}
>
> [TestFixture]
> public class ComponentRegistrationTests{
>    [Test]
>    public void DoNotAutoRegisterGenericRequestHandler(){
>
> var IOC = new Castle.Windsor.WindsorContainer();
> var type = typeof( IRequestHandler<> ).MakeGenericType( typeof
> ( GenericTestRequest<> ) );
> IOC.Register( Component.For( type ).ImplementedBy( typeof
> ( GenericTestRequestHandler<> ) ) );
>
> var requestHandler = IoC.Container.Resolve( typeof
> (IRequestHandler<GenericTestRequest<String>>));
>
> Assert.IsInstanceOf <IRequestHandler<GenericTestRequest<String>>>
> ( requestHandler );
> Assert.IsNotNull( requestHandler );
>
>
>
> }
> }
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Castle Project Users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/castle-project-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to