public static Method FromMethodInfo(MethodInfo methodInfo) { Method method = new Method { _name = methodInfo.Name, _resultType = methodInfo.ReturnType, _description = null, _parameters = new Parameter[methodInfo.GetParameters().Length], _parameterNames = new string[methodInfo.GetParameters().Length] }; foreach (ParameterInfo info in methodInfo.GetParameters()) { Parameter parameter = Parameter.FromParameterInfo(info); int position = parameter.Position; method._parameters[position] = parameter; method._parameterNames[position] = parameter.Name; } method._sortedParameters = (Parameter[])method._parameters.Clone(); InvariantStringArray.Sort(method._parameterNames, method._sortedParameters); return(method); }
public static Method FromMethodInfo(MethodInfo methodInfo) { Method method = new Method(); method._name = methodInfo.Name; method._resultType = methodInfo.ReturnType; method._description = null; method._parameters = new Parameter[methodInfo.GetParameters().Length]; method._parameterNames = new string[methodInfo.GetParameters().Length]; foreach (ParameterInfo parameterInfo in methodInfo.GetParameters()) { Parameter parameter = Parameter.FromParameterInfo(parameterInfo); int position = parameter.Position; method._parameters[position] = parameter; method._parameterNames[position] = parameter.Name; } // Keep a sorted list of parameters and their names so we can do fast look ups using binary search. method._sortedParameters = (Parameter[])method._parameters.Clone(); InvariantStringArray.Sort(method._parameterNames, method._sortedParameters); return(method); }