Hi!I'm trying to specify a custom method that will be used to create object registered in the container. I've tried to use FactorySupportFacility but:
public interface IService
{
void Hello ();
}
public class Foo : IService
{
public void Hello ()
{
Console.WriteLine ("Hello Bar");
}
}
public class Bar : IService
{
public void Hello ()
{
Console.WriteLine ("Hello Foo");
}
}
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 ())
);
}
Gives me error when registering second implementation of the service:
There is a component already registered for the given key
Castle.MicroKernel.Registration.GenericFactory`1[[Test.Program+Foo,
Test, Version=1.0.0.0, Culture=neutral.
Is it appropriate approach or some other kind of registration should be
used. I've now fallbacked to specyfying my own ComponentActivator, but
I'm looking for some shorter solution :)
smime.p7s
Description: S/MIME Cryptographic Signature
