示例#1
0
        public void Ldflda()
        {
            Redirect.ValueTypeCounter c = new Redirect.ValueTypeCounter();
            Redirect.BaseTest.Ldflda(ref c);
            Assert.AreEqual(10, c.Val);
            Redirect.BaseTest.Ldflda(ref c);
            c.Inc();
            Assert.AreEqual(21, c.Val);

            c = new Redirect.ValueTypeCounter();
            Redirect.ValueTypeCounterContainer cc = new Redirect.ValueTypeCounterContainer();
            cc.c = c;
            Redirect.BaseTest.Ldflda(ref cc);
            Assert.AreEqual(10, cc.c.i);
            Redirect.BaseTest.Ldflda(ref cc);
            cc.c.Inc();
            Assert.AreEqual(21, cc.c.Val);

            Redirect.W1 w1 = new Redirect.W1()
            {
                F = new Redirect.ValueTypeCounter()
            };

            Redirect.W2 w2 = new Redirect.W2()
            {
                F = w1
            };

            Redirect.W3 w3 = new Redirect.W3()
            {
                F = w2
            };

            Redirect.BaseTest.Ldflda(ref w1);
            Assert.AreEqual(10, w1.F.i);

            Redirect.BaseTest.Ldflda(ref w2);
            Assert.AreEqual(10, w2.F.F.i);

            Redirect.BaseTest.Ldflda(ref w3);
            Assert.AreEqual(10, w3.F.F.F.i);

            Assert.AreEqual(10, Redirect.BaseTest.Ldflda_m(ref w3));
        }
 public static int Ldflda(ref W1 p)
 {
     return(Ldflda(ref p.F));
 }