public void PosTest2()
        {
            DynamicMethod testDynMethod;
            int streamSize;
            TestILGeneratorOwner1 target = new TestILGeneratorOwner1();
            int newId = 100;

            bool actualResult;
            FieldInfo fieldInfo = _DYNAMIC_METHOD_OWNER_TYPE.GetField(
                                                c_FIELD_NAME,
                                                BindingFlags.Instance |
                                                BindingFlags.NonPublic);

            testDynMethod = this.CreateDynMethod(_DYNAMIC_METHOD_OWNER_TYPE, false);

            streamSize = 8;
            ILGenerator dynMethodIL = testDynMethod.GetILGenerator(streamSize);
            this.EmitDynMethodBody(dynMethodIL, fieldInfo);

            ILUseLikeInstance1 instanceCallBack = (ILUseLikeInstance1)testDynMethod.CreateDelegate(
                                                                                                typeof(ILUseLikeInstance1),
                                                                                                target);

            actualResult = this.VerifyILGenerator(instanceCallBack, target, newId);
            Assert.True(actualResult, "Failed to get IL generator for dynamic method.");
        }
        public void PosTest3()
        {
            DynamicMethod         testDynMethod;
            int                   streamSize;
            TestILGeneratorOwner1 target = new TestILGeneratorOwner1();
            int                   newId  = 100;

            bool      actualResult;
            FieldInfo fieldInfo = _DYNAMIC_METHOD_OWNER_TYPE.GetField(
                c_FIELD_NAME,
                BindingFlags.Instance |
                BindingFlags.NonPublic);

            testDynMethod = this.CreateDynMethod(this.CurrentModule, true);

            streamSize = 8;
            ILGenerator dynMethodIL = testDynMethod.GetILGenerator(streamSize);

            this.EmitDynMethodBody(dynMethodIL, fieldInfo);

            ILUseLikeInstance1 instanceCallBack = (ILUseLikeInstance1)testDynMethod.CreateDelegate(
                typeof(ILUseLikeInstance1),
                target);

            actualResult = this.VerifyILGenerator(instanceCallBack, target, newId);
            Assert.True(actualResult, "Failed to get IL generator for dynamic method.");
        }
        private bool VerifyILGenerator(ILUseLikeInstance1 instanceCallBack,
                                       TestILGeneratorOwner1 target,
                                       int newId)
        {
            bool retVal = false;

            retVal = target.ID == instanceCallBack(newId);
            retVal = (target.ID == newId) && retVal;
            return(retVal);
        }
 private bool VerifyILGenerator(ILUseLikeInstance1 instanceCallBack,
                                           TestILGeneratorOwner1 target,
                                           int newId)
 {
     bool retVal = false;
     retVal = target.ID == instanceCallBack(newId);
     retVal = (target.ID == newId) && retVal;
     return retVal;
 }