public ConstructorBuilder CreateConstructor(TypeBuilder type, Type[] args, ExecBld body) { var cnstr = type.DefineConstructor(MethodAttributes.Public, CallingConventions.Standard, args); body.Build(cnstr.GetILGenerator()); return(cnstr); }
public void CreateMethod(TypeBuilder type, string name, Type returnType, Type[] argType, Type interf, ExecBld body) { var equelMeth = type.DefineMethod(name, MethodAttributes.Virtual, returnType, argType); body.Build(equelMeth.GetILGenerator()); if (interf != null) { type.DefineMethodOverride(equelMeth, interf.GetMethod(name)); } }
public void AddProperty(TypeBuilder type, string propertyName, Type propertyType, ExecBld get, ExecBld set, Type prototype) { var prop = type.DefineProperty(propertyName, PropertyAttributes.None, propertyType, Type.EmptyTypes); var propSettings = MethodAttributes.Virtual; var getMeth = type.DefineMethod("get_" + propertyName, propSettings, propertyType, Type.EmptyTypes); get.Build(getMeth.GetILGenerator()); prop.SetGetMethod(getMeth); type.DefineMethodOverride(getMeth, prototype.GetMethod(getMeth.Name)); var setMeth = type.DefineMethod("set_" + propertyName, propSettings, null, new[] { propertyType }); set.Build(setMeth.GetILGenerator()); prop.SetSetMethod(setMeth); type.DefineMethodOverride(setMeth, prototype.GetMethod(setMeth.Name)); }