I want to be able to do this:
<component id="Component1" service="Foo.IFoo, Foo" 开发者_开发问答type="Foo.Bar, Foo" lifestyle="singleton" />
<component id="Component2" service="Foo.IFoo, Foo" type="Foo.Bar, Foo" lifestyle="singleton" />
Such that when I do this:
IFoo foo = m_container.Resolve<IFoo>("Component1");
Or this:
IFoo foo = m_container.Resolve<IFoo>("Component2");
..I get the same singleton instance, not a seperate instance per component.
Is this possible?
Thanks.
If all you have is the interface "Name" at runtime how are you planning to call the generic Resolve<> method on the windsor container? If you truely only want one singleton instance of IFoo regardless of the comopnent "Name" then just register one as a singleton and call:
IFoo foo = m_container.Resolve<IFoo>();
If you are looking to have multiple interfaces return the same component you can look at using Forward types.
精彩评论