Can you register an existing instance of a type in the Windsor Container?
问题 In the Windsor IOC container is it possible to register a type that I've already got an instance for, instead of having the container create it? 回答1: There is a AddComponentInstance method on the Container's Kernel property. From the Unit Tests: [Test] public void AddComponentInstance() { CustomerImpl customer = new CustomerImpl(); kernel.AddComponentInstance("key", typeof(ICustomer), customer); Assert.IsTrue(kernel.HasComponent("key")); CustomerImpl customer2 = kernel["key"] as CustomerImpl;