Create an InjectionConstructor
and pass that to RegisterType()
:
var unityContainer = new UnityContainer();
ISnuh snuh = new Snuh();
InjectionConstructor injectionConstructor = new InjectionConstructor(snuh);
unityContainer.RegisterType<ICalculator, SimpleCalculator>(injectionConstructor);
If you have to do it only when you resolve the type, that's when ResolverOverride[]
would be used:
public static T Resolve<T>(this IUnityContainer container, params ResolverOverride[] overrides);
Per MSDN:
Use ParameterOverride to override the specified constructor parameter
or parameters.