I make extensive use of the interface-based Typed Factory Facility in Windsor, but there are times when I must pass a lot of arguments to a factory around with the factory itself. I'd much prefer to create a factory factory with these arguments so that I don't need to muddy up the constructors of objects more than I need to.
For example, assume I have this factory (registered with Castle using .AsFactory()):
public interface IFooFactory
{
IFoo Create(IBar bar, IBaz baz);
}
If I want to create an IFoo, I'd do something like this:
public class DummyClass
{
public DummyClass(IFooFactory fooFactory, IBarProvider barProvider, IBaz baz)
{
fooFactory.Create(barProvider.Bar, baz);
}
}
What I'd like is to be able to define this:
public interface IFooFactoryFactory
{
IFooFactory Create(IBaz baz);
}
And register it with Castle using AsFactory(). This way I could then remove the vagabond parameter baz if I constructed IFooFactory like so:
public void CreateDummies(IFooFactoryFactory fooFactoryFactory, IBarProvider barProvider, IBaz baz)
{
IFooFactory fooFactory = fooFactoryFactory.Create(baz);
var dummy = dummyFactory.Create(fooFactory, barProvider);
}
I'm fairly certain this isn't possible in Windsor's current release, but I thought I'd ask in case I'm missing it.