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); }
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()); } }
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()); } }
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); }