Specifying instance for registration of a component with Castle Windsor

后端 未结 2 653
我在风中等你
我在风中等你 2021-02-18 23:03

I have what is probably a simple question here about Castle Windsor, which I haven\'t been using for very long. I\'m trying to register a service with a specific instance that w

相关标签:
2条回答
  • 2021-02-18 23:11

    You can do that through the Kernel property of the container:

    container.Kernel.AddComponentInstance<IMyInterface>(serviceObj);
    
    0 讨论(0)
  • 2021-02-18 23:14

    Try using the AddComponentInstance method on the container's Kernel object. I think this is what you need.


    Please note: This technique is now deprecated. Use container.Register(Component.For<T>().Instance(myT)); instead (thanks to eouw0o83hf)

    0 讨论(0)
提交回复
热议问题