Unity - how to use multiple mappings for the same type and inject into an object
问题 I'm using Unity 2.0 and in the following code I'm trying to inject a specific tool in the Worker object. I would like to use the following code. But ofcourse there is an error "Resolution of the dependency failed". I believe I should be able to do something like this, but I'm having a difficult time figuring it out. IUnityContainer container = new UnityContainer(); container.RegisterType<IWorker, Worker>("Worker") .RegisterType<ITool, ToolA>("ToolA") .RegisterType<ITool, ToolB>("ToolB")