Esempio n. 1
0
        public void TestThatAtNameReturnsTheObjectItself2()
        {
            var lfi = new LinkedFieldInfo(typeof(List <int>), "@");
            var x   = typeof(List <int>);

            Assert.IsTrue(ReferenceEquals(x, lfi.GetValue(x)));
            Assert.AreEqual(typeof(IEnumerable <int>), lfi.IEnumerable);
            Assert.AreEqual(typeof(List <int>), lfi.FieldType);
        }
Esempio n. 2
0
        public void TestThatAtNameReturnsTheObjectItself()
        {
            var lfi = new LinkedFieldInfo(typeof(TestClassData), "@");
            var x   = new TestClassData();

            Assert.IsTrue(ReferenceEquals(x, lfi.GetValue(x)));
            Assert.IsNull(lfi.IEnumerable);
            Assert.AreEqual(typeof(TestClassData), lfi.FieldType);
        }
Esempio n. 3
0
        public void Performance()
        {
            var tc   = new TestClassData();
            var lfi1 = new LinkedFieldInfo(tc.GetType(), "D");

            for (var i = 0; i < 10; i++)
            {
                var d  = 0.0;
                var sw = Stopwatch.StartNew();
                for (var j = 0; j < 1000000; j++)
                {
                    d += (double)lfi1.GetValue(tc);
                }
                Console.Write(sw.ElapsedMilliseconds + "  ");
                sw.Restart();
                for (var j = 0; j < 1000000; j++)
                {
                    d += (double)lfi1.GetValueSlower(tc);
                }
                Console.WriteLine(sw.ElapsedMilliseconds.ToString());
                Console.WriteLine();
            }
        }