On 2010-02-23 08:27, Maciej Paszta wrote:
private static void Main (string[] args)
{
WindsorContainer c = new WindsorContainer ();
c.AddFacility<FactorySupportFacility> ();
c.Register (Component.For<IService> ()
.ImplementedBy<Foo> ()
.Named ("foo.implementation")
.UsingFactoryMethod (() => new Foo ()),
Component.For<IService> ()
.ImplementedBy<Bar> ()
.Named ("boo.implementation")
.UsingFactoryMethod (() => new Foo ())
);
Argh!!! My bad, should be Bar here - this would work. Nevertheless, the problem remains. I have a method (dynamic method) which is built in runtime and returns instances of the service that I'm registering (hence is compiled to delegate - IService CreateProxyForService()). The method itself returns specific instance of the IService, but since call to UsingFactoryMethod registers GenericFactory<T> under it's full name, the key in the container will be the same for several implementations (GenericFactory[IService,foo].....). Of course custom component activator resolves this constraint, but is it really necessary to register factories under their qualified name, what if GenericFactory could return types of S not T?
smime.p7s
Description: S/MIME Cryptographic Signature
