示例#1
0
        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);
            }
        }
示例#2
0
        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);
            }
        }