示例#1
0
        /// <summary>
        /// Inflate the token
        /// </summary>
        /// <param name="source">Stream to inflate the token from</param>
        /// <returns>TRUE if inflation is complete</returns>
        public bool Inflate(Stream source)
        {
            // Read user type
            UserType = TDSUtilities.ReadUInt(source);

            // Read flags
            Flags = new TDSColumnDataFlags(TDSUtilities.ReadUShort(source));

            // Read server type
            DataType = (TDSDataType)source.ReadByte();

            // Dispatch further reading based on the type
            switch (DataType)
            {
            case TDSDataType.Binary:
            case TDSDataType.VarBinary:
            case TDSDataType.Char:
            case TDSDataType.VarChar:
            // The above types are deprecated after TDS 7205.

            case TDSDataType.BitN:
            case TDSDataType.Guid:
            case TDSDataType.IntN:
            case TDSDataType.MoneyN:
            case TDSDataType.FloatN:
            case TDSDataType.DateTimeN:
            {
                // Byte length
                DataTypeSpecific = source.ReadByte();
                break;
            }

            case TDSDataType.DateN:
            {
                // No details
                DataTypeSpecific = null;
                break;
            }

            case TDSDataType.TimeN:
            case TDSDataType.DateTime2N:
            case TDSDataType.DateTimeOffsetN:
            {
                // Scale
                DataTypeSpecific = source.ReadByte();
                break;
            }

            case TDSDataType.DecimalN:
            case TDSDataType.NumericN:
            {
                // Read values
                byte length    = (byte)source.ReadByte();
                byte precision = (byte)source.ReadByte();
                byte scale     = (byte)source.ReadByte();

                // Decimal data type specific
                DataTypeSpecific = new TDSDecimalColumnSpecific(length, precision, scale);
                break;
            }

            case TDSDataType.BigBinary:
            case TDSDataType.BigVarBinary:
            {
                // Short length
                DataTypeSpecific = TDSUtilities.ReadUShort(source);
                break;
            }

            case TDSDataType.BigChar:
            case TDSDataType.BigVarChar:
            case TDSDataType.NChar:
            case TDSDataType.NVarChar:
            {
                // SHILOH CHAR types have collation associated with it.
                TDSShilohVarCharColumnSpecific typedSpecific = new TDSShilohVarCharColumnSpecific();

                // Read length
                typedSpecific.Length = TDSUtilities.ReadUShort(source);

                // Create collation
                typedSpecific.Collation = new TDSColumnDataCollation();

                // Read collation
                typedSpecific.Collation.WCID   = TDSUtilities.ReadUInt(source);
                typedSpecific.Collation.SortID = (byte)source.ReadByte();

                DataTypeSpecific = typedSpecific;
                break;
            }

            case TDSDataType.Text:
            case TDSDataType.NText:
            {
                // YukonTextType.Len + YukonTextType.tdsCollationInfo + YukonTextType.cParts
                // cb = sizeof(LONG) + sizeof(TDSCOLLATION) + sizeof(BYTE);
                break;
            }

            case TDSDataType.Image:
            {
                // Data length
                DataTypeSpecific = TDSUtilities.ReadUInt(source);
                break;
            }

            case TDSDataType.SSVariant:
            {
                // Data length
                DataTypeSpecific = TDSUtilities.ReadUInt(source);
                break;
            }

            case TDSDataType.Udt:
            {
                // hr = GetUDTColFmt(pvOwner, dwTimeout);
                break;
            }

            case TDSDataType.Xml:
            {
                // cb = sizeof(lpColFmt->YukonXmlType.bSchemaPresent);
                break;
            }
            }

            // Check if table name is available
            if (DataType == TDSDataType.Text || DataType == TDSDataType.NText || DataType == TDSDataType.Image)
            {
                // Allocate table name container
                TableName = new List <string>();

                // Read part count
                byte partCount = (byte)source.ReadByte();

                // Write each part
                for (byte bPart = 0; bPart < partCount; bPart++)
                {
                    // Read table part length and value
                    TableName.Add(TDSUtilities.ReadString(source, (ushort)(TDSUtilities.ReadUShort(source) * 2)));
                }
            }

            // Read column name
            Name = TDSUtilities.ReadString(source, (ushort)(source.ReadByte() * 2));

            return(true);
        }
示例#2
0
        /// <summary>
        /// Inflate the token
        /// </summary>
        /// <param name="source">Stream to inflate the token from</param>
        /// <returns>TRUE if inflation is complete</returns>
        public bool Inflate(Stream source)
        {
            // Read user type
            UserType = TDSUtilities.ReadUInt(source);

            // Read flags
            Flags = new TDSColumnDataFlags(TDSUtilities.ReadUShort(source));

            // Read server type
            DataType = (TDSDataType)source.ReadByte();

            // Dispatch further reading based on the type
            switch (DataType)
            {
                case TDSDataType.Binary:
                case TDSDataType.VarBinary:
                case TDSDataType.Char:
                case TDSDataType.VarChar:
                // The above types are deprecated after TDS 7205.

                case TDSDataType.BitN:
                case TDSDataType.Guid:
                case TDSDataType.IntN:
                case TDSDataType.MoneyN:
                case TDSDataType.FloatN:
                case TDSDataType.DateTimeN:
                    {
                        // Byte length
                        DataTypeSpecific = source.ReadByte();
                        break;
                    }
                case TDSDataType.DateN:
                    {
                        // No details
                        DataTypeSpecific = null;
                        break;
                    }
                case TDSDataType.TimeN:
                case TDSDataType.DateTime2N:
                case TDSDataType.DateTimeOffsetN:
                    {
                        // Scale
                        DataTypeSpecific = source.ReadByte();
                        break;
                    }
                case TDSDataType.DecimalN:
                case TDSDataType.NumericN:
                    {
                        // Read values
                        byte length = (byte)source.ReadByte();
                        byte precision = (byte)source.ReadByte();
                        byte scale = (byte)source.ReadByte();

                        // Decimal data type specific
                        DataTypeSpecific = new TDSDecimalColumnSpecific(length, precision, scale);
                        break;
                    }
                case TDSDataType.BigBinary:
                case TDSDataType.BigVarBinary:
                    {
                        // Short length
                        DataTypeSpecific = TDSUtilities.ReadUShort(source);
                        break;
                    }
                case TDSDataType.BigChar:
                case TDSDataType.BigVarChar:
                case TDSDataType.NChar:
                case TDSDataType.NVarChar:
                    {
                        // SHILOH CHAR types have collation associated with it.
                        TDSShilohVarCharColumnSpecific typedSpecific = new TDSShilohVarCharColumnSpecific();

                        // Read length
                        typedSpecific.Length = TDSUtilities.ReadUShort(source);

                        // Create collation
                        typedSpecific.Collation = new TDSColumnDataCollation();

                        // Read collation
                        typedSpecific.Collation.WCID = TDSUtilities.ReadUInt(source);
                        typedSpecific.Collation.SortID = (byte)source.ReadByte();

                        DataTypeSpecific = typedSpecific;
                        break;
                    }
                case TDSDataType.Text:
                case TDSDataType.NText:
                    {
                        // YukonTextType.Len + YukonTextType.tdsCollationInfo + YukonTextType.cParts
                        // cb = sizeof(LONG) + sizeof(TDSCOLLATION) + sizeof(BYTE);
                        break;
                    }
                case TDSDataType.Image:
                    {
                        // Data length
                        DataTypeSpecific = TDSUtilities.ReadUInt(source);
                        break;
                    }
                case TDSDataType.SSVariant:
                    {
                        // Data length
                        DataTypeSpecific = TDSUtilities.ReadUInt(source);
                        break;
                    }
                case TDSDataType.Udt:
                    {
                        // hr = GetUDTColFmt(pvOwner, dwTimeout);
                        break;
                    }
                case TDSDataType.Xml:
                    {
                        // cb = sizeof(lpColFmt->YukonXmlType.bSchemaPresent);
                        break;
                    }
            }

            // Check if table name is available
            if (DataType == TDSDataType.Text || DataType == TDSDataType.NText || DataType == TDSDataType.Image)
            {
                // Allocate table name container
                TableName = new List<string>();

                // Read part count
                byte partCount = (byte)source.ReadByte();

                // Write each part
                for (byte bPart = 0; bPart < partCount; bPart++)
                {
                    // Read table part length and value
                    TableName.Add(TDSUtilities.ReadString(source, (ushort)(TDSUtilities.ReadUShort(source) * 2)));
                }
            }

            // Read column name
            Name = TDSUtilities.ReadString(source, (ushort)(source.ReadByte() * 2));

            return true;
        }
示例#3
0
 /// <summary>
 /// Default constructor
 /// </summary>
 public TDSColumnData()
 {
     // Create flags
     Flags = new TDSColumnDataFlags();
 }
示例#4
0
 /// <summary>
 /// Default constructor
 /// </summary>
 public TDSColumnData()
 {
     // Create flags
     Flags = new TDSColumnDataFlags();
 }