public static object Resolve(this IComponentContext componentContext, Type instanceType) { if (!componentContext.TryResolve(instanceType, out var instance)) { ContextException.ResolveErr(instanceType); } return(instance); }
public static T Resolve <T>(this IComponentContext componentContext) { if (!componentContext.TryResolve <T>(out var instance)) { ContextException.ResolveErr(typeof(T)); } return(instance); }
public override object ActivateInstance(IComponentContext context) { var ctor = DefaultConstructor(); var @params = ctor.GetParameters(); var paramInstances = new object[@params.Length]; for (int i = 0; i < @params.Length; i++) { var argType = @params[i].ParameterType; if (!context.TryResolve(argType, out var param)) { ContextException.ResolveErr(argType); } paramInstances[i] = param; } return(CtorCompiler()(paramInstances)); }