I have constructor
Foo(IColor c , int someNumber)
and I know the some number only during the run time, and I want to call this constructor during the resolving and to pass someNumber
value and the IColor
to be resolved autocratically.
Something like this:
container.Resolve<IFoo>(someNumber);
Is it possible to be done ?
You should prefer Typed Factory instead of using container like service locator. Just define factory interface:
public interface IFooFactory {
IFoo Create(int somenumber);
}
and register it as typed factory:
container.Register(Component.For<IFooFactory>().AsFactory());
Then use dependency injection to inject factory and use it:
var foo = fooFactory.Create(desiredArgumentValue);
For more info read Windsor documentation
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With