internal void ReadSqlValueInternal(SqlBuffer value, byte tdsType, int typeId, int length, TdsParserStateObject stateObj)
        {
            int num4;
            switch (tdsType)
            {
                case 0x7f:
                    goto Label_011A;

                case 0xa5:
                case 0xad:
                case 0x22:
                case 0x25:
                case 0x2d:
                {
                    byte[] buff = new byte[length];
                    stateObj.ReadByteArray(buff, 0, length);
                    value.SqlBinary = new SqlBinary(buff, true);
                    return;
                }
                case 0x6d:
                    if (length != 4)
                    {
                        goto Label_013B;
                    }
                    goto Label_012D;

                case 110:
                    if (length == 4)
                    {
                        goto Label_0173;
                    }
                    goto Label_014E;

                case 0x6f:
                    if (length != 4)
                    {
                        goto Label_01A2;
                    }
                    goto Label_0187;

                case 0x7a:
                    goto Label_0173;

                case 0x62:
                    this.ReadSqlVariant(value, length, stateObj);
                    return;

                case 0x68:
                case 50:
                    value.Boolean = stateObj.ReadByte() != 0;
                    return;

                case 0x23:
                case 0x2e:
                case 0x2f:
                case 0x31:
                case 0x33:
                case 0x35:
                case 0x36:
                case 0x37:
                case 0x39:
                    return;

                case 0x24:
                {
                    byte[] buffer2 = new byte[length];
                    stateObj.ReadByteArray(buffer2, 0, length);
                    value.SqlGuid = new SqlGuid(buffer2, true);
                    return;
                }
                case 0x26:
                    if (length == 1)
                    {
                        break;
                    }
                    if (length == 2)
                    {
                        goto Label_00FE;
                    }
                    if (length != 4)
                    {
                        goto Label_011A;
                    }
                    goto Label_010C;

                case 0x30:
                    break;

                case 0x34:
                    goto Label_00FE;

                case 0x38:
                    goto Label_010C;

                case 0x3a:
                    goto Label_0187;

                case 0x3b:
                    goto Label_012D;

                case 60:
                    goto Label_014E;

                case 0x3d:
                    goto Label_01A2;

                case 0x3e:
                    goto Label_013B;

                default:
                    return;
            }
            value.Byte = stateObj.ReadByte();
            return;
        Label_00FE:
            value.Int16 = stateObj.ReadInt16();
            return;
        Label_010C:
            value.Int32 = stateObj.ReadInt32();
            return;
        Label_011A:
            value.Int64 = stateObj.ReadInt64();
            return;
        Label_012D:
            value.Single = stateObj.ReadSingle();
            return;
        Label_013B:
            value.Double = stateObj.ReadDouble();
            return;
        Label_014E:
            num4 = stateObj.ReadInt32();
            uint num3 = stateObj.ReadUInt32();
            long num2 = (num4 << 0x20) + num3;
            value.SetToMoney(num2);
            return;
        Label_0173:
            value.SetToMoney((long) stateObj.ReadInt32());
            return;
        Label_0187:
            value.SetToDateTime(stateObj.ReadUInt16(), stateObj.ReadUInt16() * SqlDateTime.SQLTicksPerMinute);
            return;
        Label_01A2:
            value.SetToDateTime(stateObj.ReadInt32(), (int) stateObj.ReadUInt32());
        }
 internal SqlReturnValue ProcessReturnValue(int length, TdsParserStateObject stateObj)
 {
     int tokenLength;
     uint num8;
     SqlReturnValue metaData = new SqlReturnValue {
         length = length
     };
     if (this._isYukon)
     {
         metaData.parmIndex = stateObj.ReadUInt16();
     }
     byte num2 = stateObj.ReadByte();
     if (num2 > 0)
     {
         metaData.parameter = stateObj.ReadString(num2);
     }
     stateObj.ReadByte();
     if (this.IsYukonOrNewer)
     {
         num8 = stateObj.ReadUInt32();
     }
     else
     {
         num8 = stateObj.ReadUInt16();
     }
     stateObj.ReadUInt16();
     byte tdsType = stateObj.ReadByte();
     if (tdsType == 0xf1)
     {
         tokenLength = 0xffff;
     }
     else if (this.IsVarTimeTds(tdsType))
     {
         tokenLength = 0;
     }
     else if (tdsType == 40)
     {
         tokenLength = 3;
     }
     else
     {
         tokenLength = this.GetTokenLength(tdsType, stateObj);
     }
     metaData.metaType = MetaType.GetSqlDataType(tdsType, num8, tokenLength);
     metaData.type = metaData.metaType.SqlDbType;
     if (this._isShiloh)
     {
         metaData.tdsType = metaData.metaType.NullableType;
         metaData.isNullable = true;
         if (tokenLength == 0xffff)
         {
             metaData.metaType = MetaType.GetMaxMetaTypeFromMetaType(metaData.metaType);
         }
     }
     else
     {
         if (metaData.metaType.NullableType == tdsType)
         {
             metaData.isNullable = true;
         }
         metaData.tdsType = tdsType;
     }
     if (metaData.type == SqlDbType.Decimal)
     {
         metaData.precision = stateObj.ReadByte();
         metaData.scale = stateObj.ReadByte();
     }
     if (metaData.metaType.IsVarTime)
     {
         metaData.scale = stateObj.ReadByte();
     }
     if (tdsType == 240)
     {
         this.ProcessUDTMetaData(metaData, stateObj);
     }
     if (metaData.type == SqlDbType.Xml)
     {
         if ((stateObj.ReadByte() & 1) != 0)
         {
             num2 = stateObj.ReadByte();
             if (num2 != 0)
             {
                 metaData.xmlSchemaCollectionDatabase = stateObj.ReadString(num2);
             }
             num2 = stateObj.ReadByte();
             if (num2 != 0)
             {
                 metaData.xmlSchemaCollectionOwningSchema = stateObj.ReadString(num2);
             }
             short num7 = stateObj.ReadInt16();
             if (num7 != 0)
             {
                 metaData.xmlSchemaCollectionName = stateObj.ReadString(num7);
             }
         }
     }
     else if (this._isShiloh && metaData.metaType.IsCharType)
     {
         metaData.collation = this.ProcessCollation(stateObj);
         int codePage = this.GetCodePage(metaData.collation, stateObj);
         if (codePage == this._defaultCodePage)
         {
             metaData.codePage = this._defaultCodePage;
             metaData.encoding = this._defaultEncoding;
         }
         else
         {
             metaData.codePage = codePage;
             metaData.encoding = Encoding.GetEncoding(metaData.codePage);
         }
     }
     bool isNull = false;
     ulong num5 = this.ProcessColumnHeader(metaData, stateObj, out isNull);
     int num4 = (num5 > 0x7fffffffL) ? 0x7fffffff : ((int) num5);
     if (metaData.metaType.IsPlp)
     {
         num4 = 0x7fffffff;
     }
     if (isNull)
     {
         this.GetNullSqlValue(metaData.value, metaData);
         return metaData;
     }
     this.ReadSqlValue(metaData.value, metaData, num4, stateObj);
     return metaData;
 }
        private void CommonProcessMetaData(TdsParserStateObject stateObj, _SqlMetaData col)
        {
            uint num5;
            int length = 0;
            if (this.IsYukonOrNewer)
            {
                num5 = stateObj.ReadUInt32();
            }
            else
            {
                num5 = stateObj.ReadUInt16();
            }
            byte num3 = stateObj.ReadByte();
            col.updatability = (byte) ((num3 & 11) >> 2);
            col.isNullable = 1 == (num3 & 1);
            col.isIdentity = 0x10 == (num3 & 0x10);
            stateObj.ReadByte();
            col.isColumnSet = 4 == (num3 & 4);
            byte tdsType = stateObj.ReadByte();
            if (tdsType == 0xf1)
            {
                col.length = 0xffff;
            }
            else if (this.IsVarTimeTds(tdsType))
            {
                col.length = 0;
            }
            else if (tdsType == 40)
            {
                col.length = 3;
            }
            else
            {
                col.length = this.GetTokenLength(tdsType, stateObj);
            }
            col.metaType = MetaType.GetSqlDataType(tdsType, num5, col.length);
            col.type = col.metaType.SqlDbType;
            if (this._isShiloh)
            {
                col.tdsType = col.isNullable ? col.metaType.NullableType : col.metaType.TDSType;
            }
            else
            {
                col.tdsType = tdsType;
            }
            if (this._isYukon)
            {
                if (240 == tdsType)
                {
                    this.ProcessUDTMetaData(col, stateObj);
                }
                if (col.length == 0xffff)
                {
                    col.metaType = MetaType.GetMaxMetaTypeFromMetaType(col.metaType);
                    col.length = 0x7fffffff;
                    if ((tdsType == 0xf1) && ((stateObj.ReadByte() & 1) != 0))
                    {
                        length = stateObj.ReadByte();
                        if (length != 0)
                        {
                            col.xmlSchemaCollectionDatabase = stateObj.ReadString(length);
                        }
                        length = stateObj.ReadByte();
                        if (length != 0)
                        {
                            col.xmlSchemaCollectionOwningSchema = stateObj.ReadString(length);
                        }
                        length = stateObj.ReadInt16();
                        if (length != 0)
                        {
                            col.xmlSchemaCollectionName = stateObj.ReadString(length);
                        }
                    }
                }
            }
            if (col.type == SqlDbType.Decimal)
            {
                col.precision = stateObj.ReadByte();
                col.scale = stateObj.ReadByte();
            }
            if (col.metaType.IsVarTime)
            {
                col.scale = stateObj.ReadByte();
                switch (col.metaType.SqlDbType)
                {
                    case SqlDbType.Time:
                        col.length = MetaType.GetTimeSizeFromScale(col.scale);
                        break;

                    case SqlDbType.DateTime2:
                        col.length = 3 + MetaType.GetTimeSizeFromScale(col.scale);
                        break;

                    case SqlDbType.DateTimeOffset:
                        col.length = 5 + MetaType.GetTimeSizeFromScale(col.scale);
                        break;
                }
            }
            if ((this._isShiloh && col.metaType.IsCharType) && (tdsType != 0xf1))
            {
                col.collation = this.ProcessCollation(stateObj);
                int codePage = this.GetCodePage(col.collation, stateObj);
                if (codePage == this._defaultCodePage)
                {
                    col.codePage = this._defaultCodePage;
                    col.encoding = this._defaultEncoding;
                }
                else
                {
                    col.codePage = codePage;
                    col.encoding = Encoding.GetEncoding(col.codePage);
                }
            }
            if (col.metaType.IsLong && !col.metaType.IsPlp)
            {
                if (this._isYukon)
                {
                    int num7 = 0xffff;
                    col.multiPartTableName = this.ProcessOneTable(stateObj, ref num7);
                }
                else
                {
                    length = stateObj.ReadUInt16();
                    string multipartName = stateObj.ReadString(length);
                    col.multiPartTableName = new MultiPartTableName(multipartName);
                }
            }
            length = stateObj.ReadByte();
            col.column = stateObj.ReadString(length);
            stateObj._receivedColMetaData = true;
        }
 internal SqlCollation ProcessCollation(TdsParserStateObject stateObj)
 {
     return new SqlCollation { info = stateObj.ReadUInt32(), sortId = stateObj.ReadByte() };
 }