示例#1
0
        internal static SqlUdtInfo GetFromType(Type target)
        {
            SqlUdtInfo fromType = TryGetFromType(target);

            if (fromType == null)
            {
                throw new InvalidOperationException("SqlUdtReason_NoUdtAttribute");
            }
            return(fromType);
        }
示例#2
0
        internal static SqlUdtInfo TryGetFromType(Type target)
        {
            if (types2UdtInfo == null) {
                types2UdtInfo = new Dictionary<Type, SqlUdtInfo>();
            }

            SqlUdtInfo sqlUdtInfo;

            if (!types2UdtInfo.TryGetValue(target, out sqlUdtInfo)) {
                object[] customAttributes = target.GetCustomAttributes(typeof(SqlUserDefinedTypeAttribute), false);

                if (customAttributes.Length == 1) {
                    sqlUdtInfo = new SqlUdtInfo((SqlUserDefinedTypeAttribute)customAttributes[0]);
                }

                types2UdtInfo.Add(target, sqlUdtInfo);
            }

            return sqlUdtInfo;
        }
示例#3
0
        internal static SqlUdtInfo TryGetFromType(Type target)
        {
            if (types2UdtInfo == null)
            {
                types2UdtInfo = new Dictionary <Type, SqlUdtInfo>();
            }

            SqlUdtInfo sqlUdtInfo;

            if (!types2UdtInfo.TryGetValue(target, out sqlUdtInfo))
            {
                object[] customAttributes = target.GetCustomAttributes(typeof(SqlUserDefinedTypeAttribute), false);

                if (customAttributes.Length == 1)
                {
                    sqlUdtInfo = new SqlUdtInfo((SqlUserDefinedTypeAttribute)customAttributes[0]);
                }

                types2UdtInfo.Add(target, sqlUdtInfo);
            }

            return(sqlUdtInfo);
        }