private static MethodReference GetMethodReference(TypeDefinition declaringType, string methodName, bool allowGenericResolving) { var method = (from x in declaringType.Methods where x.Name == methodName select x).FirstOrDefault(); if (method == null) { return null; } MethodReference methodReference = method; if (declaringType.HasGenericParameters && allowGenericResolving) { methodReference = method.MakeGeneric(declaringType); } return methodReference; } #endregion