private static bool TryFindPartialMatch(this ConstructorInfo constructor, object[] constructorArguments, out Activation instanceInfo) { ParameterInfo[] parameters = constructor.GetParameters(); var paramIndex = 0; var newArguments = new object[parameters.Length]; var args = new List <object>(constructorArguments); var exactOrder = true; foreach (ParameterInfo param in parameters) { if (TryUseArgument(param, args, out var arg, ref exactOrder)) { newArguments[paramIndex] = arg; }
private static object InvokeConcrete(this Activation activation, object[] constructorArguments) => activation .ConstructorInfo .Invoke(constructorArguments);
private static bool TryFindExactMatch(this ConstructorInfo constructor, object[] constructorArguments, out Activation instanceInfo) { ParameterInfo[] parameters = constructor.GetParameters(); var exactMatchFound = parameters.Length == constructorArguments.Length && (parameters.Length == 0 || parameters .Select((param, i) => param.IsInstanceOf(constructorArguments[i])) .All(x => x)); instanceInfo = exactMatchFound ? new Activation { Arguments = constructorArguments, ConstructorInfo = constructor, Match = ArgumentMatch.Exact } : null; return(exactMatchFound); }