Example #1
0
 public static ConstructorInfo GetConstructorSmart(this Type type, Type[] parameterTypes)
 {
     if (type.IsGenericType && type.ContainsTypeBuilders())
     {
         var genericDefinition = type.GetGenericTypeDefinition();
         var constructorInfo = genericDefinition.GetConstructor(parameterTypes);
         return TypeBuilder.GetConstructor(type, constructorInfo);
     }
     return type.GetConstructor(parameterTypes);
 }
Example #2
0
 public static MethodInfo GetMethodSmart(this Type type, string methodName)
 {
     if (type.IsGenericType && type.ContainsTypeBuilders())
     {
         var genericDefinition = type.GetGenericTypeDefinition();
         var methodInfo = genericDefinition.GetMethod(methodName);
         return TypeBuilder.GetMethod(type, methodInfo);
     }
     return type.GetMethod(methodName);
 }
Example #3
0
 //获取
 public static MethodInfo GetMethodSmart(this Type type, Func<MethodInfo, bool> isCorrectMethod)
 {
     if (type.IsGenericType && type.ContainsTypeBuilders())
     {
         var genericDefinition = type.GetGenericTypeDefinition();
         var methodInfo = genericDefinition.GetMethods().Single(isCorrectMethod);
         return TypeBuilder.GetMethod(type, methodInfo);
     }
     return type.GetMethods().Single(isCorrectMethod);
 }