/// <summary>
        /// 获取属性值
        /// </summary>
        /// <param name="target">拥有该成员的类实例</param>
        /// <returns></returns>
        private object Get(object target)
        {
            if (!_property.CanRead)
            {
                throw new XFrameworkException("{0} is unreadable", base.FullName);
            }

            if (_get == null)
            {
                _get = PropertyAccessor.InitializeGetter(_property);
            }
            return(_get(target));
        }
Exemple #2
0
        /// <summary>
        /// 创建成员反射器
        /// </summary>
        /// <param name="member">元数据</param>
        /// <returns></returns>
        public static MemberAccessorBase Create(MemberInfo member)
        {
            MemberAccessorBase m = null;

            if (member.MemberType == MemberTypes.Property)
            {
                m = new PropertyAccessor((PropertyInfo)member);
            }
            else if (member.MemberType == MemberTypes.Field)
            {
                m = new FieldAccessor((FieldInfo)member);
            }
            else if (member.MemberType == MemberTypes.Method)
            {
                m = new MethodAccessor((MethodInfo)member);
            }

            if (m == null)
            {
                throw new XFrameworkException("{0}.{1} not supported", member.ReflectedType, member.Name);
            }
            return(m);
        }