public ILBuilder GetMember(TinyMember mm) { if (mm.IsProperty) { var method = (mm.Property).GetGetMethod(true); return(CallVirtual(method)); } return(LoadField((FieldInfo)mm.Field)); }
public ILBuilder SetMember(TinyMember mm) { if (mm.IsProperty) { var method = mm.Property.GetSetMethod(true); return(CallVirtual(method)); } return(SetField(mm.Field)); }
private static void GenerateSetValue(Type model, TypeBuilder builder, TinyMember info, Type memberType) { var method = builder.DefineMethod("SetValue", CtMethodAttr, null, new Type[] { objectType, objectType }); var processor = new ILBuilder(method.GetILGenerator()); processor.LoadArg(1).Cast(model).LoadArg(2).CastOrUnbox(memberType); processor.SetMember(info); processor.Return(); }
private static void GenerateSetValue(Type model, TypeBuilder builder, TinyMember info, Type memberType) { var method = builder.DefineMethod("SetValue", CtMethodAttr, null, new Type[]{objectType, objectType}); var processor = new ILBuilder(method.GetILGenerator()); processor.LoadArg(1).Cast(model).LoadArg(2).CastOrUnbox(memberType); processor.SetMember(info); processor.Return(); }
private static void GenerateGetValue(Type model, TypeBuilder builder, TinyMember info, Type memberType) { var method = builder.DefineMethod("GetValue", CtMethodAttr, objectType, new Type[] { objectType }); var processor = new ILBuilder(method.GetILGenerator()); processor.DeclareLocal(objectType); processor.LoadArg(1).Cast(model); processor.GetMember(info); if (memberType.IsValueType) { processor.Box(memberType); } processor.SetLoc(0); processor.LoadLoc(0); processor.Return(); }
private static void GenerateGetValue(Type model, TypeBuilder builder, TinyMember info, Type memberType) { var method = builder.DefineMethod("GetValue", CtMethodAttr, objectType, new Type[]{objectType}); var processor = new ILBuilder(method.GetILGenerator()); processor.DeclareLocal(objectType); processor.LoadArg(1).Cast(model); processor.GetMember(info); if (memberType.IsValueType) { processor.Box(memberType); } processor.SetLoc(0); processor.LoadLoc(0); processor.Return(); }
public ILBuilder GetMember(TinyMember mm) { if (mm.IsProperty) { var method = (mm.Property).GetGetMethod(true); return CallVirtual(method); } return LoadField((FieldInfo)mm.Field); }
public ILBuilder SetMember(TinyMember mm) { if(mm.IsProperty) { var method = mm.Property.GetSetMethod(true); return CallVirtual(method); } return SetField(mm.Field); }