public void Field_2_RepeatILEmit() { var test = new TargetClass(); int tmp = 0; var get = ILEmit.CreateGetFieldValueDelegate <int>(typeof(TargetClass).GetField("Field")); var set = ILEmit.CreateSetFieldValueDelegate <int>(typeof(TargetClass).GetField("Field")); for (int i = 0; i < repeats; i++) { set(test, i); tmp = get(test); } }
public void Property_2_RepeatILEmit() { var test = new TargetClass(); int tmp = 0; var get = ILEmit.CreateGetPropertyValueDelegate <int>(typeof(TargetClass).GetProperty("Property")); var set = ILEmit.CreateSetPropertyValueDelegate <int>(typeof(TargetClass).GetProperty("Property")); for (int i = 0; i < repeats; i++) { set(test, i); tmp = get(test); } }