English 中文(简体)
温饱和注射问题
原标题:Windsor Dependency Injection Problem with generics

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(Component.For(IRepo<Person>).ImplementedBy(UserRepo).LifeStyle.PerWebRequest);

这似乎并不可行。

我这样做的次序是,我登记这一具体执行情况,然后将所有接口装上并登记到大会的类型。

这似乎并不可行。

最佳回答

<代码>DefaultInterface >n t support generals. 您可使用<条码>所有界面,也可通过<条码>选择<>条码/代码>方法使用习惯战略。

问题回答

暂无回答




相关问题
castle IOC - resolving circular references

quick question for my MVP implementation: currently I have the code below, in which both the presenter and view are resolved via the container. Then the presenter calls View.Init to pass himself to ...

Castle Windsor auto registration

I currently have the following registration set up private static void AddFrameworkComponentsTo(IWindsorContainer container) { container.AddComponent<ITypeConverter, TypeConversionFacade>();...

Authorization and Windsor

I m trying to implement my custom authorize attribute like: public class MyCustomAuth : AuthorizeAttribute { private readonly IUserService _userService; public MyCustomAuth(IUserService ...

How can I override a component registered in Castle Windsor?

I m just starting with Windsor, so please be gentle :) I have a scenario where I want to be able to override/replace components placed inside a windsor container. Read on ... In my prod code, I want ...

热门标签