static public ConstructorBuilderEX CreateConstructor(this TypeBuilder item, MethodAttributes attributes, Operation <ILStatement, ConstructorBuilderEX> operation, IEnumerable <Type> parameter_types) { ConstructorBuilderEX constructor_builder = item.CreateConstructorBuilder(attributes, parameter_types); ILBody.Write(constructor_builder, operation(constructor_builder)); return(constructor_builder); }
static public MethodBuilderEX CreateMethod(this TypeBuilder item, string name, MethodAttributes method_attributes, Type return_type, Operation <ILStatement, MethodBuilderEX> operation, IEnumerable <Type> parameter_types) { MethodBuilderEX method_builder = item.CreateMethodBuilder(name, method_attributes, return_type, parameter_types); ILBody.Write(method_builder, operation(method_builder)); return(method_builder); }
static public ILBody Write(MethodBase method, ILGenerator generator, ILStatement statement) { ILBody body = new ILBody(method, statement); body.Write(generator); return(body); }
static public T CreateDynamicMethodDelegate <T>(this Type item, string name, Operation <ILStatement, MethodBase> operation) { Type delegate_type = typeof(T); MethodInfo delegate_method = delegate_type.GetDelegateMethod(); DynamicMethod dynamic_method = item.CreateDynamicMethod(name, delegate_method.ReturnType, delegate_method.GetTechnicalParameterTypes()); ILBody body = ILBody.Write(dynamic_method, operation(dynamic_method)); T to_return = dynamic_method.CreateDelegate <T>(); DYNAMIC_IL_BODY.Add(to_return, body); return(to_return); }