コード例 #1
0
 /// <summary>
 /// 设置属性值
 /// </summary>
 /// <param name="obj"></param>
 /// <param name="property"></param>
 /// <param name="value"></param>
 public static void SetPropertyValue(object obj, PropertyInfo property, object value)
 {
     if (property.CanWrite)
     {
         var propertySetter = DynamicCalls.GetPropertySetter(property);
         value = ConvertValue(property.PropertyType, value);
         propertySetter(obj, value);
     }
 }
コード例 #2
0
        public void GetPropertySetterTest()
        {
            PropertyInfo           propInfo = null; // TODO: 初始化为适当的值
            FastPropertySetHandler expected = null; // TODO: 初始化为适当的值
            FastPropertySetHandler actual;

            actual = DynamicCalls.GetPropertySetter(propInfo);
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("验证此测试方法的正确性。");
        }
コード例 #3
0
 public PropertyHandler(PropertyInfo property)
 {
     if (property.CanWrite)
     {
         this.mSetValue = DynamicCalls.GetPropertySetter(property);
     }
     if (property.CanRead)
     {
         this.mGetValue = DynamicCalls.GetPropertyGetter(property);
     }
     this.mProperty = property;
 }