标签: dependency-injection ioc-container ninject
是否可以使用Ninject按键返回组件实例?
相当于温莎城堡是为了前:
container.Register(Component.For< ConcreteA>()。Named(“KeyForConcreteA”));
答案 0 :(得分:2)
Bind<ConcreteA>().ToSelf().Named("KeyForConcreteA") var a = kernel.Get<ConcreteA>("KeyForConcreteA");