I have a constructor like this that I would like to pass arguments to from a factory:
public Event(IRegisteredType registeredEarly, IPassNow passNowByInterface,
DateTimeOffset local, DateTimeOffset world)
{
// ...
}
I tried this approach, but it did not work, because both local and world values where the same, one overwrote the other:
public Event CreateEvent(IPassNow passNow, DateTimeOffset local, DateTimeOffset world)
{
var args = new Arguments { { typeof(IPassNow), passNow } };
args.InsertTypedCollection(new object[] { local, world });
return _container.Resolve<Event>(args);
}
- registeredEarly should be resolved automatically, it is registered at composition root, and that works
- passNowByInterface should be passed at resolution-time, but because it is an interface I need to specify the interface type, because otherwise Castle Windsor will try to use the concrete type of the argument, again that works - see Failure to pass generic arguments with Castle Windsor
- local and world need to be passed at resolution-time as well, but note they are both the same concrete type and I cannot rely on variable names - see Resolution-time arguments of same type in Castle Windsor
- I cannot get the last to work with the rest?