English 中文(简体)
解决同一接口有两个论点的建筑商?
原标题:Resolving a constructor with two arguments of the same interface?

另一位发展者,今天有这次谈话:

<>Me: 依赖性注射是冷却, lo。

<>Dennis: 当我需要一个实例来说明“Stuff”类和唯一的“I”构造者是“Stuff(ISome Interface 界面1, ISomeInterface界面2)”具体类型完全不同?

<>Me:

我们把团结用作我们首选的集装箱。 我如何登记,当我需要解决Some Interface问题时,具体类型可能是两种不同类型?

最佳回答

检查参数Override。 它允许你以姓名具体说明参数:

   container.Resolve<IDoStuff>(new ParameterOverrides<DoStuff> { { "interface1", new SomeInterfaceImpl() }, { "interface2", AnotherSomeInterfaceImpl() } });
问题回答

暂无回答




相关问题
How to Inject Open Connections with an IoC

First, my scenario. I have a service, BillingService, has a constructor like this: BillingService(IInstallmentService, IBillingRepository) The InstallmentService has a constructor that looks like ...

Using the Ninject kernel as a Unit of Work object factory

So I m starting to use Ninject for dependency injection and I m wondering what people think of using a kernel as an object factory for Unit of Work type objects like Linq2Sql Datacontexts. I would ...

array dependency injection in spring?

is there a way to use dependency injection to inject all available implementations of a specific interface in spring? This is kind of the same thing as asked here for .NET. Though my aim is to use @...

Unity constructors

I have setup unity in my project and it is working for objects that don t have constructor injection implemented on them. The issue is now I do have an object which requires a custom object as a ...

Grails Packaging and Naming Conventions

Packaging Controllers, Services,etc. i.e. - com.company.controllers - com.company.services Is this a good practice or should be avoided by all means?? Another worth mentioning problem I encountered ...

ASP.NET MVP Injecting Service Dependency

I have an ASP.NET page that implements my view and creates the presenter in the page constuctor. Phil Haack s post providing was used as the starting point, and I ll just the examples from the post ...

Authorization and Windsor

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

热门标签