Пример #1
0
 private void TestOptimizedMultiSetter(object target, int iter)
 {
     for (var i = 0; i < iter; i++)
     {
         _optimizer.SetPropertyValues(target, GetValues());
     }
 }
Пример #2
0
        public void TestGetterTypeMismatch()
        {
            var          obj      = new GetterTypeMismatchClass();
            const string property = "Property";

            NoSetterAccessor accessor = new NoSetterAccessor(new CamelCaseUnderscoreStrategy());

            Assert.IsTrue(accessor.CanAccessThroughReflectionOptimizer);

            ReflectionOptimizer reflectionOptimizer = new ReflectionOptimizer(
                obj.GetType(),
                new[] { accessor.GetGetter(obj.GetType(), property) },
                new[] { accessor.GetSetter(obj.GetType(), property) });

            IAccessOptimizer accessOptimizer = reflectionOptimizer.AccessOptimizer;

            accessOptimizer.SetPropertyValues(obj, new object[] { 10 });
            object[] values = accessOptimizer.GetPropertyValues(obj);

            Assert.AreEqual("str", values[0]);
        }