Esempio n. 1
0
        public void GetterGenericFuncCached()
        {
            var reflectionCache = new ReflectionCache();

            var propertyInfo = typeof(Foo).GetProperty(nameof(Foo.Property1));
            var func         = reflectionCache.GetPropertyGetter <string>(propertyInfo);

            Assert.IsNotNull(func);
            var func2 = reflectionCache.GetPropertyGetter <string>(propertyInfo);

            Assert.IsNotNull(func2);

            Assert.AreEqual(func, func2);
        }
Esempio n. 2
0
        public void GetPropertyFuncAndRetrieveValue()
        {
            var reflectionCache = new ReflectionCache();

            var propertyInfo = typeof(Foo).GetProperty(nameof(Foo.Property1));

            foreach (DelegateCreationMode mode in delegateCreationModes)
            {
                InvokeUsingMode(mode);
            }

            void InvokeUsingMode(DelegateCreationMode mode)
            {
                var func = reflectionCache.GetPropertyGetter(propertyInfo, mode);

                Assert.IsNotNull(func, mode.ToString());

                var          foo            = new Foo();
                const string expectedValue1 = "Foo";

                foo.Property1 = expectedValue1;

                var property1 = func(foo);

                Assert.AreEqual(expectedValue1, property1, mode.ToString());
            }
        }
Esempio n. 3
0
        public void GetterFuncCached()
        {
            var reflectionCache = new ReflectionCache();

            var propertyInfo = typeof(Foo).GetProperty(nameof(Foo.Property1));

            foreach (DelegateCreationMode mode in delegateCreationModes)
            {
                InvokeUsingMode(mode);
            }

            void InvokeUsingMode(DelegateCreationMode mode)
            {
                var func = reflectionCache.GetPropertyGetter(propertyInfo, mode);

                Assert.IsNotNull(func, mode.ToString());
                var func2 = reflectionCache.GetPropertyGetter(propertyInfo, mode);

                Assert.IsNotNull(func2, mode.ToString());

                Assert.AreEqual(func, func2, mode.ToString());
            }
        }
Esempio n. 4
0
        public void GetPropertyFuncAndRetrieveValue()
        {
            var reflectionCache = new ReflectionCache();

            var propertyInfo = typeof(Foo).GetProperty(nameof(Foo.Property1));
            var func         = reflectionCache.GetPropertyGetter(propertyInfo);

            Assert.IsNotNull(func);

            var          foo            = new Foo();
            const string expectedValue1 = "Foo";

            foo.Property1 = expectedValue1;

            var property1 = func(foo);

            Assert.AreEqual(expectedValue1, property1);
        }