Пример #1
0
        internal NormalizedSerializer(Type t) : base(t)
        {
            SqlUserDefinedTypeAttribute udtAttribute = SerializationHelperSql9.GetUdtAttribute(t);

            this.m_normalizer  = new BinaryOrderedUdtNormalizer(t, true);
            this.m_isFixedSize = udtAttribute.IsFixedLength;
            this.m_maxSize     = this.m_normalizer.Size;
        }
Пример #2
0
        internal static int GetUdtMaxLength(Type t)
        {
            SqlUdtInfo udtInfo = SqlUdtInfo.GetFromType(t);

            if (Format.Native == udtInfo.SerializationFormat)
            {
                //In the native format, the user does not specify the
                //max byte size, it is computed from the type definition
                return(SerializationHelperSql9.SizeInBytes(t));
            }
            else
            {
                //In all other formats, the user specifies the maximum size in bytes.
                return(udtInfo.MaxByteSize);
            }
        }
        internal SmiMetaData(System.Data.SqlDbType dbType, long maxLength, byte precision, byte scale, long localeId, SqlCompareOptions compareOptions, System.Type userDefinedType, string udtAssemblyQualifiedName, bool isMultiValued, IList <SmiExtendedMetaData> fieldTypes, SmiMetaDataPropertyCollection extendedProperties)
        {
            this.SetDefaultsForType(dbType);
            switch (dbType)
            {
            case System.Data.SqlDbType.Binary:
            case System.Data.SqlDbType.VarBinary:
                this._maxLength = maxLength;
                goto Label_01BF;

            case System.Data.SqlDbType.Char:
            case System.Data.SqlDbType.NChar:
            case System.Data.SqlDbType.NVarChar:
            case System.Data.SqlDbType.VarChar:
                this._maxLength      = maxLength;
                this._localeId       = localeId;
                this._compareOptions = compareOptions;
                goto Label_01BF;

            case System.Data.SqlDbType.Decimal:
                this._precision = precision;
                this._scale     = scale;
                this._maxLength = __maxLenFromPrecision[precision - 1];
                goto Label_01BF;

            case System.Data.SqlDbType.NText:
            case System.Data.SqlDbType.Text:
                this._localeId       = localeId;
                this._compareOptions = compareOptions;
                goto Label_01BF;

            case System.Data.SqlDbType.Udt:
                this._clrType = userDefinedType;
                if (null == userDefinedType)
                {
                    this._maxLength = maxLength;
                    break;
                }
                this._maxLength = SerializationHelperSql9.GetUdtMaxLength(userDefinedType);
                break;

            case System.Data.SqlDbType.Structured:
                if (fieldTypes != null)
                {
                    this._fieldMetaData = new List <SmiExtendedMetaData>(fieldTypes).AsReadOnly();
                }
                this._isMultiValued = isMultiValued;
                this._maxLength     = this._fieldMetaData.Count;
                goto Label_01BF;

            case System.Data.SqlDbType.Time:
                this._scale     = scale;
                this._maxLength = 5 - __maxVarTimeLenOffsetFromScale[scale];
                goto Label_01BF;

            case System.Data.SqlDbType.DateTime2:
                this._scale     = scale;
                this._maxLength = 8 - __maxVarTimeLenOffsetFromScale[scale];
                goto Label_01BF;

            case System.Data.SqlDbType.DateTimeOffset:
                this._scale     = scale;
                this._maxLength = 10 - __maxVarTimeLenOffsetFromScale[scale];
                goto Label_01BF;

            default:
                goto Label_01BF;
            }
            this._udtAssemblyQualifiedName = udtAssemblyQualifiedName;
Label_01BF:
            if (extendedProperties != null)
            {
                extendedProperties.SetReadOnly();
                this._extendedProperties = extendedProperties;
            }
        }