public static string Format(MethodInfo method) { if (ReferenceEquals(method.ReflectedType, null)) { return(Format(ReflectionExtensions.GetReturnType(method)) + " " + FormatMethodWithoutParameters(method) + "(" + string.Join(", ", ReflectionExtensions.GetParameterTypes(method).Select(Format).ToArray()) + ")"); } return(Format(ReflectionExtensions.GetReturnType(method)) + " " + Format(method.ReflectedType) + "." + FormatMethodWithoutParameters(method) + "(" + string.Join(", ", ReflectionExtensions.GetParameterTypes(method).Select(Format).ToArray()) + ")"); }
public Type[] GetInterfaces() { return(SubstituteGenericParameters(ReflectionExtensions.GetInterfaces(m_type), m_type.GetGenericArguments(), m_inst)); }
public static string Format(ConstructorInfo constructor) { return(Format(constructor.ReflectedType) + ".ctor" + "(" + string.Join(", ", ReflectionExtensions.GetParameterTypes(constructor).Select(Format).ToArray()) + ")"); }
private static int GetOccurrenceCount(this Type[] ax, Type ty) { return(Array.FindAll(ax, x => Array.Exists(ReflectionExtensions.GetInterfaces(x), tx => ReflectionExtensions.Equal(tx, ty))).Length); }
private static Type[] Subtract(this Type[] ax, Type[] ay) { return(Array.FindAll(ax, x => false == Array.Exists(ay, y => ReflectionExtensions.Equal(x, y)))); }
// // public static Type FindEqualTypeWith(this Type type1, Type type2) // { // var baseClass = type2.FindBaseClassWith(type1); // var interfaze = type2.FindInterfaceWith(type1); // // if(interfaze == null) // return baseClass; // if(baseClass == null || baseClass == typeof(object) || baseClass.IsAbstract) // return interfaze; // return baseClass; // } public static Type[] Intersect(this Type[] ax, Type[] ay) { return(Array.FindAll(ax, x => Array.Exists(ay, y => ReflectionExtensions.Equal(x, y)))); }
public static T EmitDynamicMethod <T, TTarget>(string name, Module m, Action <GroboIL> emitCode, TTarget target) where T : class { var delegateType = typeof(T); //HACK var methodInfo = delegateType.GetMethod("Invoke", BindingFlags.Public | BindingFlags.Instance); if (methodInfo == null) { throw new ArgumentException($"Type {delegateType} is not a Delegate"); } var dynamicMethod = new DynamicMethod(name, methodInfo.ReturnType, Concat(typeof(TTarget), ReflectionExtensions.GetParameterTypes(methodInfo)), m, true); using (var il = new GroboIL(dynamicMethod)) emitCode(il); return(CreateDelegate <T>(dynamicMethod, target)); }