internal protected object[] MergeConstructorParameters(InjectionContext context) { object[] result = null; var myParams = context.Parameters; if (_ctorDependencyProviders != null) { if (myParams == null || myParams.Length == 0) { result = new object[_ctorDependencyProviders.Length]; for (var i = 0; i < _ctorDependencyProviders.Length; i++) { _ctorDependencyProviders[i].CreateObject(context, out result[i]); } } else { var paramLength = myParams.Length - 1; if (paramLength > _ctorDependencyProviders.Length - 1) { throw ParameterException.ParameterNumberExceeds(context, _ctorDependencyProviders.Length, myParams.Length); } switch (myParams.ParameterKind) { case ParameterKind.Positional: result = MergePositionalParameters(context, myParams); break; case ParameterKind.Named: result = MergeNamedParameters(context, myParams); break; } } } else { if (myParams != null && myParams.Length > 0) { throw ParameterException.RedundantParametersProvided(context); } } return(result); }
protected static Exception ParameterNumberExceeds(InjectionContext context, int neededParamNumber, int providedParamNumber) { return(ParameterException.ParameterNumberExceeds(context, neededParamNumber, providedParamNumber)); }