I have an Interface IRepo <Entity>
. I have a generic implementation Repo<Entity>
.
Now i just do the following
Container.Register(AllTypes.FromAssemblyNamed("assemblyname").Pick() .WithService.DefaultInterface() .Configure(c => c.LifeStyle.PerWebRequest))
and register all the interface with respective implementations. This seems to work fine.
My Problem arises when i try to be more specific.
If i try to map IRepo<Person>
with Person being a class subclassing Entity with <UserRepo>
using
Container.Register(C开发者_如何学Pythonomponent.For(IRepo<Person>
).ImplementedBy(UserRepo).LifeStyle.PerWebRequest);
It does not seem to work.
The order in which i am doing this is that i am registering this specific implementation and then loading and registering all the interfaces to types from the assembly.
It does not seem to work.
DefaultInterface
doesn't support generics. You can use AllInterfaces
instead or a custom strategy via Select
method
精彩评论