Ejemplo n.º 1
0
        /// <summary>
        /// 设置属性值
        /// </summary>
        /// <param name="p">属性对象</param>
        /// <param name="instance">实体对象</param>
        /// <param name="newValue">新值</param>
        /// <param name="index">索引置空</param>
        public static void SetValue2(this PropertyInfo p, object instance, object newValue, object[] index = null)
        {
            var ma = new DynamicMethodMemberAccessor();

            ma.SetValue(instance, p.Name, newValue);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 获取属性值
        /// </summary>
        /// <param name="p">属性对象</param>
        /// <param name="instance">实体对象</param>
        /// <param name="index">索引置空</param>
        /// <returns></returns>
        public static object GetValue2(this PropertyInfo p, object instance, object[] index = null)
        {
            var ma = new DynamicMethodMemberAccessor();

            return(ma.GetValue(instance, p.Name));
        }