예제 #1
0
        public void SetTest()
        {
            var model = new Model {
                name = "laojiu"
            };
            var setter = LambdaUtil.CreateSetAction <object, object>(model.GetType().GetProperty("name"));

            setter.Invoke(model, "ee");
            Assert.True("ee" == model.name);
        }
        /// <summary>
        /// 属性描述
        /// </summary>
        /// <param name="property">属性信息</param>
        public PropertyDescriptor(PropertyInfo property)
        {
            this.Name = property.Name;
            this.Info = property;

            if (property.CanRead == true)
            {
                this.geter = LambdaUtil.CreateGetFunc <TDeclaring, TProperty>(property);
            }

            if (property.CanWrite == true)
            {
                this.seter = LambdaUtil.CreateSetAction <TDeclaring, TProperty>(property);
            }
        }