Exemple #1
0
        /// <summary>
        /// 获取字段或属性成员的 <see cref="ColumnAttribute"/>
        /// </summary>
        /// <param name="member">字段或属性成员</param>
        /// <param name="reflectedType">调用字段或属性成员的实际类型</param>
        /// <returns></returns>
        public static ColumnAttribute GetColumnAttribute(MemberInfo member, Type reflectedType)
        {
            if (member == null)
            {
                return(null);
            }

            if (reflectedType == null)
            {
                reflectedType = member.ReflectedType ?? member.DeclaringType;
            }
            ColumnAttribute column = null;

            if (!TypeUtils.IsAnonymousType(reflectedType) && !TypeUtils.IsPrimitiveType(reflectedType))
            {
                var typeRuntime = TypeRuntimeInfoCache.GetRuntimeInfo(reflectedType);
                var m           = typeRuntime.GetMember(member.Name);
                if (m != null)
                {
                    column = m.Column;
                }
            }

            return(column);
        }
Exemple #2
0
        /// <summary>
        /// 获取指定成员的 <see cref="ColumnAttribute"/>
        /// </summary>
        /// <param name="member">成员</param>
        /// <param name="objType">成员所在类型</param>
        /// <returns></returns>
        public virtual ColumnAttribute GetColumnAttribute(MemberInfo member, Type objType)
        {
            Type dataType = TypeUtils.GetDataType(member);

            if (dataType == null)
            {
                return(null);
            }

            ColumnAttribute column = null;
            Type            type   = objType != null ? objType : (member.ReflectedType != null ? member.ReflectedType : member.DeclaringType);

            if (type != null && !TypeUtils.IsAnonymousType(type) && !TypeUtils.IsPrimitiveType(type))
            {
                TypeRuntimeInfo typeRuntime = TypeRuntimeInfoCache.GetRuntimeInfo(type);
                var             invoker     = typeRuntime.GetInvoker(member.Name);
                if (invoker != null)
                {
                    column = invoker.Column;
                }
            }

            return(column);
        }
Exemple #3
0
 /// <summary>
 /// 初始化 <see cref="TypeRuntimeInfo"/> 类的新实例
 /// </summary>
 /// <param name="type">类型声明</param>
 internal TypeRuntimeInfo(Type type)
 {
     _type            = type;
     _isAnonymousType = TypeUtils.IsAnonymousType(_type);
 }
Exemple #4
0
 /// <summary>
 /// 初始化 <see cref="TypeRuntimeInfo"/> 类的新实例
 /// </summary>
 /// <param name="type">类型声明</param>
 /// <param name="private">包含私有成员</param>
 internal TypeRuntimeInfo(Type type, bool @private)
 {
     _type            = type;
     _isAnonymousType = TypeUtils.IsAnonymousType(_type);
     _private         = @private;
 }
 /// <summary>
 /// 初始化 <see cref="TypeRuntimeInfo"/> 类的新实例
 /// </summary>
 /// <param name="type">类型声明</param>
 /// <param name="includePrivates">包含私有成员</param>
 internal TypeRuntimeInfo(Type type, bool includePrivates)
 {
     _type            = type;
     _isAnonymousType = TypeUtils.IsAnonymousType(_type);
     _includePrivates = includePrivates;
 }