having the following classes and interfaces:
private class ClassToResolve
{
public ClassToResolve(ConstructorArgument arg1, ConstructorArgument arg2, IConstructorArgument2 arg3)
{
}
}
private class ConstructorArgument
{
}
private class ConstructorArgument2 : IConstructorArgument2
{
}
private interface IConstructorArgument2
{
}
Imagine that I have the following registration:
UnityContainer container = new UnityContainer();
container.RegisterType<IConstructorArgument2, ConstructorArgument2>("A");
container.RegisterType<IConstructorArgument2, ConstructorArgument2>("B");
// How to register this?
container.RegisterType<ClassToResolve, ClassToResolve>(...
ClassToResolve result = container.Resolve<ClassToResolve>();
I'm trying a way to not have to usean InjectionContructor that forces me to put all the contructor arguments as this is becoming a nightmare on the project we are working as everytime dependencies change we have to modify lots of registrations.
In this case I would like to have a way to do something like: container.RegisterType<ClassToResolve, ClassToResolve>(new ResolvedParameter<IConstructorArgument2>("arg3", "A");
Is this possible with the UnityContainer or writting an extension to it?
Thanks.