static bool MethodHasOverloadForApiOptions(MethodInfo methodInfo, ParameterInfo[] expected) { var actual = methodInfo.GetParameters(); if (actual.Length != expected.Length + 1) { return false; } for (var i = 0; i < expected.Length; i++) { var a = actual.ElementAt(i); var e = expected.ElementAt(i); if (a.Name != e.Name) { return false; } if (a.ParameterType != e.ParameterType) { return false; } } var lastParameter = actual.Last(); return lastParameter.Name == "options" && lastParameter.ParameterType == typeof(ApiOptions); }
private bool HasTwoParametersNeeded(ParameterInfo[] parameters, TypeInfo eventArgsType, TypeInfo extraPropertyType) { return parameters.Count() == 2 && HasOneParameterNeeded(parameters, eventArgsType) && ( extraPropertyType != null && parameters.ElementAt(1).ParameterType.GetTypeInfo().IsAssignableFrom(extraPropertyType) || parameters.ElementAt(1).ParameterType.GetTypeInfo().IsValueType == false ); }
private bool HasOneParameterNeeded(ParameterInfo[] parameters, TypeInfo eventArgsType) { return parameters.Any() && parameters.ElementAt(0).ParameterType.GetTypeInfo().IsAssignableFrom(eventArgsType); }