string ValueAsString(BinXmlToken token) { try { CheckValueTokenBounds(); switch ( token ) { case BinXmlToken.SQL_NCHAR: case BinXmlToken.SQL_NVARCHAR: case BinXmlToken.SQL_NTEXT: return GetString( this.tokDataPos, this.tokLen ); case BinXmlToken.XSD_BOOLEAN: { if ( 0 == this.data[this.tokDataPos] ) return "false"; else return "true"; } case BinXmlToken.SQL_BIT: case BinXmlToken.SQL_TINYINT: case BinXmlToken.SQL_SMALLINT: case BinXmlToken.SQL_INT: case BinXmlToken.SQL_BIGINT: case BinXmlToken.XSD_BYTE: case BinXmlToken.XSD_UNSIGNEDSHORT: case BinXmlToken.XSD_UNSIGNEDINT: return ValueAsLong().ToString( CultureInfo.InvariantCulture ); case BinXmlToken.XSD_UNSIGNEDLONG: return ValueAsULong().ToString( CultureInfo.InvariantCulture ); case BinXmlToken.SQL_REAL: return XmlConvert.ToString( GetSingle( this.tokDataPos ) ); case BinXmlToken.SQL_FLOAT: return XmlConvert.ToString( GetDouble( this.tokDataPos ) ); case BinXmlToken.SQL_UUID: { int a; short b, c; int pos = this.tokDataPos; a = GetInt32( pos ); b = GetInt16( pos + 4 ); c = GetInt16( pos + 6 ); Guid v = new Guid( a, b, c, data[pos + 8], data[pos + 9], data[pos + 10], data[pos + 11], data[pos + 12], data[pos + 13], data[pos + 14], data[pos + 15] ); return v.ToString(); } case BinXmlToken.SQL_SMALLMONEY: { BinXmlSqlMoney v = new BinXmlSqlMoney( GetInt32( this.tokDataPos ) ); return v.ToString(); } case BinXmlToken.SQL_MONEY: { BinXmlSqlMoney v = new BinXmlSqlMoney( GetInt64( this.tokDataPos ) ); return v.ToString(); } case BinXmlToken.XSD_DECIMAL: case BinXmlToken.SQL_DECIMAL: case BinXmlToken.SQL_NUMERIC: { BinXmlSqlDecimal v = new BinXmlSqlDecimal( this.data, this.tokDataPos, token == BinXmlToken.XSD_DECIMAL ); return v.ToString(); } case BinXmlToken.SQL_CHAR: case BinXmlToken.SQL_VARCHAR: case BinXmlToken.SQL_TEXT: { int pos = this.tokDataPos; int codepage = GetInt32( pos ); Encoding enc = System.Text.Encoding.GetEncoding( codepage ); return enc.GetString( this.data, pos + 4, this.tokLen - 4 ); } case BinXmlToken.SQL_VARBINARY: case BinXmlToken.SQL_BINARY: case BinXmlToken.SQL_IMAGE: case BinXmlToken.SQL_UDT: case BinXmlToken.XSD_BASE64: { return Convert.ToBase64String( this.data, this.tokDataPos, this.tokLen ); } case BinXmlToken.XSD_BINHEX: return BinHexEncoder.Encode( this.data, this.tokDataPos, this.tokLen ); case BinXmlToken.SQL_DATETIME: case BinXmlToken.SQL_SMALLDATETIME: case BinXmlToken.XSD_TIME: case BinXmlToken.XSD_DATE: case BinXmlToken.XSD_DATETIME: case BinXmlToken.XSD_KATMAI_DATE: case BinXmlToken.XSD_KATMAI_DATETIME: case BinXmlToken.XSD_KATMAI_TIME: case BinXmlToken.XSD_KATMAI_DATEOFFSET: case BinXmlToken.XSD_KATMAI_DATETIMEOFFSET: case BinXmlToken.XSD_KATMAI_TIMEOFFSET: return ValueAsDateTimeString(); case BinXmlToken.XSD_QNAME: { int nameNum = ParseMB32( this.tokDataPos ); if ( nameNum < 0 || nameNum >= this.symbolTables.qnameCount ) throw new XmlException( Res.XmlBin_InvalidQNameID, String.Empty ); QName qname = this.symbolTables.qnametable[nameNum]; if ( qname.prefix.Length == 0 ) return qname.localname; else return String.Concat( qname.prefix, ":", qname.localname ); } default: throw ThrowUnexpectedToken( this.token ); } } catch { this.state = ScanState.Error; throw; } }
object ValueAsObject(BinXmlToken token, bool returnInternalTypes) { CheckValueTokenBounds(); switch (token) { case BinXmlToken.SQL_NCHAR: case BinXmlToken.SQL_NVARCHAR: case BinXmlToken.SQL_NTEXT: return GetString(this.tokDataPos, this.tokLen); case BinXmlToken.XSD_BOOLEAN: return (0 != this.data[this.tokDataPos]); case BinXmlToken.SQL_BIT: return (Int32)this.data[this.tokDataPos]; case BinXmlToken.SQL_TINYINT: return this.data[this.tokDataPos]; case BinXmlToken.SQL_SMALLINT: return GetInt16(this.tokDataPos); case BinXmlToken.SQL_INT: return GetInt32(this.tokDataPos); case BinXmlToken.SQL_BIGINT: return GetInt64(this.tokDataPos); case BinXmlToken.XSD_BYTE: { sbyte v = unchecked((sbyte)this.data[this.tokDataPos]); return v; } case BinXmlToken.XSD_UNSIGNEDSHORT: return GetUInt16(this.tokDataPos); case BinXmlToken.XSD_UNSIGNEDINT: return GetUInt32(this.tokDataPos); case BinXmlToken.XSD_UNSIGNEDLONG: return GetUInt64(this.tokDataPos); case BinXmlToken.SQL_REAL: return GetSingle(this.tokDataPos); case BinXmlToken.SQL_FLOAT: return GetDouble(this.tokDataPos); case BinXmlToken.SQL_UUID: { int a; short b, c; int pos = this.tokDataPos; a = GetInt32(pos); b = GetInt16(pos + 4); c = GetInt16(pos + 6); Guid v = new Guid(a, b, c, data[pos + 8], data[pos + 9], data[pos + 10], data[pos + 11], data[pos + 12], data[pos + 13], data[pos + 14], data[pos + 15]); return v.ToString(); } case BinXmlToken.SQL_SMALLMONEY: { BinXmlSqlMoney v = new BinXmlSqlMoney(GetInt32(this.tokDataPos)); if (returnInternalTypes) return v; else return v.ToDecimal(); } case BinXmlToken.SQL_MONEY: { BinXmlSqlMoney v = new BinXmlSqlMoney(GetInt64(this.tokDataPos)); if (returnInternalTypes) return v; else return v.ToDecimal(); } case BinXmlToken.XSD_DECIMAL: case BinXmlToken.SQL_DECIMAL: case BinXmlToken.SQL_NUMERIC: { BinXmlSqlDecimal v = new BinXmlSqlDecimal(this.data, this.tokDataPos, token == BinXmlToken.XSD_DECIMAL); if (returnInternalTypes) return v; else return v.ToDecimal(); } case BinXmlToken.SQL_CHAR: case BinXmlToken.SQL_VARCHAR: case BinXmlToken.SQL_TEXT: { int pos = this.tokDataPos; int codepage = GetInt32(pos); Encoding enc = System.Text.Encoding.GetEncoding(codepage); return enc.GetString(this.data, pos + 4, this.tokLen - 4); } case BinXmlToken.SQL_VARBINARY: case BinXmlToken.SQL_BINARY: case BinXmlToken.SQL_IMAGE: case BinXmlToken.SQL_UDT: case BinXmlToken.XSD_BASE64: case BinXmlToken.XSD_BINHEX: { byte[] data = new byte[this.tokLen]; Array.Copy(this.data, this.tokDataPos, data, 0, this.tokLen); return data; } case BinXmlToken.SQL_DATETIME: case BinXmlToken.SQL_SMALLDATETIME: case BinXmlToken.XSD_TIME: case BinXmlToken.XSD_DATE: case BinXmlToken.XSD_DATETIME: case BinXmlToken.XSD_KATMAI_DATE: case BinXmlToken.XSD_KATMAI_DATETIME: case BinXmlToken.XSD_KATMAI_TIME: return ValueAsDateTime(); case BinXmlToken.XSD_KATMAI_DATEOFFSET: case BinXmlToken.XSD_KATMAI_DATETIMEOFFSET: case BinXmlToken.XSD_KATMAI_TIMEOFFSET: return ValueAsDateTimeOffset(); case BinXmlToken.XSD_QNAME: { int nameNum = ParseMB32(this.tokDataPos); if (nameNum < 0 || nameNum >= this.symbolTables.qnameCount) throw new XmlException(Res.XmlBin_InvalidQNameID, String.Empty); QName qname = this.symbolTables.qnametable[nameNum]; return new XmlQualifiedName(qname.localname, qname.namespaceUri); } default: throw ThrowUnexpectedToken(this.token); } }
Decimal ValueAsDecimal() { CheckValueTokenBounds(); switch (token) { case BinXmlToken.SQL_BIT: case BinXmlToken.SQL_TINYINT: case BinXmlToken.SQL_SMALLINT: case BinXmlToken.SQL_INT: case BinXmlToken.SQL_BIGINT: case BinXmlToken.XSD_BYTE: case BinXmlToken.XSD_UNSIGNEDSHORT: case BinXmlToken.XSD_UNSIGNEDINT: return new Decimal(ValueAsLong()); case BinXmlToken.XSD_UNSIGNEDLONG: return new Decimal(ValueAsULong()); case BinXmlToken.SQL_REAL: return new Decimal(GetSingle(this.tokDataPos)); case BinXmlToken.SQL_FLOAT: return new Decimal(GetDouble(this.tokDataPos)); case BinXmlToken.SQL_SMALLMONEY: { BinXmlSqlMoney v = new BinXmlSqlMoney(GetInt32(this.tokDataPos)); return v.ToDecimal(); } case BinXmlToken.SQL_MONEY: { BinXmlSqlMoney v = new BinXmlSqlMoney(GetInt64(this.tokDataPos)); return v.ToDecimal(); } case BinXmlToken.XSD_DECIMAL: case BinXmlToken.SQL_DECIMAL: case BinXmlToken.SQL_NUMERIC: { BinXmlSqlDecimal v = new BinXmlSqlDecimal(this.data, this.tokDataPos, token == BinXmlToken.XSD_DECIMAL); return v.ToDecimal(); } default: throw ThrowUnexpectedToken(this.token); } }
private string ValueAsString(BinXmlToken token) { string str; try { int num8; this.CheckValueTokenBounds(); switch (token) { case BinXmlToken.SQL_SMALLINT: case BinXmlToken.SQL_INT: case BinXmlToken.SQL_BIT: case BinXmlToken.SQL_TINYINT: case BinXmlToken.SQL_BIGINT: case BinXmlToken.XSD_BYTE: case BinXmlToken.XSD_UNSIGNEDSHORT: case BinXmlToken.XSD_UNSIGNEDINT: return this.ValueAsLong().ToString(CultureInfo.InvariantCulture); case BinXmlToken.SQL_REAL: return XmlConvert.ToString(this.GetSingle(this.tokDataPos)); case BinXmlToken.SQL_FLOAT: return XmlConvert.ToString(this.GetDouble(this.tokDataPos)); case BinXmlToken.SQL_MONEY: { BinXmlSqlMoney money2 = new BinXmlSqlMoney(this.GetInt64(this.tokDataPos)); return money2.ToString(); } case BinXmlToken.SQL_UUID: { int tokDataPos = this.tokDataPos; int a = this.GetInt32(tokDataPos); short b = this.GetInt16(tokDataPos + 4); short c = this.GetInt16(tokDataPos + 6); Guid guid = new Guid(a, b, c, this.data[tokDataPos + 8], this.data[tokDataPos + 9], this.data[tokDataPos + 10], this.data[tokDataPos + 11], this.data[tokDataPos + 12], this.data[tokDataPos + 13], this.data[tokDataPos + 14], this.data[tokDataPos + 15]); return guid.ToString(); } case BinXmlToken.SQL_DECIMAL: case BinXmlToken.SQL_NUMERIC: case BinXmlToken.XSD_DECIMAL: { BinXmlSqlDecimal num5 = new BinXmlSqlDecimal(this.data, this.tokDataPos, token == BinXmlToken.XSD_DECIMAL); return num5.ToString(); } case BinXmlToken.SQL_BINARY: case BinXmlToken.SQL_VARBINARY: case BinXmlToken.SQL_IMAGE: case BinXmlToken.SQL_UDT: case BinXmlToken.XSD_BASE64: return Convert.ToBase64String(this.data, this.tokDataPos, this.tokLen); case BinXmlToken.SQL_CHAR: case BinXmlToken.SQL_VARCHAR: case BinXmlToken.SQL_TEXT: { int pos = this.tokDataPos; return Encoding.GetEncoding(this.GetInt32(pos)).GetString(this.data, pos + 4, this.tokLen - 4); } case BinXmlToken.SQL_NCHAR: case BinXmlToken.SQL_NVARCHAR: case BinXmlToken.SQL_NTEXT: return this.GetString(this.tokDataPos, this.tokLen); case BinXmlToken.SQL_DATETIME: case BinXmlToken.SQL_SMALLDATETIME: case BinXmlToken.XSD_KATMAI_TIMEOFFSET: case BinXmlToken.XSD_KATMAI_DATETIMEOFFSET: case BinXmlToken.XSD_KATMAI_DATEOFFSET: case BinXmlToken.XSD_KATMAI_TIME: case BinXmlToken.XSD_KATMAI_DATETIME: case BinXmlToken.XSD_KATMAI_DATE: case BinXmlToken.XSD_TIME: case BinXmlToken.XSD_DATETIME: case BinXmlToken.XSD_DATE: return this.ValueAsDateTimeString(); case BinXmlToken.SQL_SMALLMONEY: { BinXmlSqlMoney money = new BinXmlSqlMoney(this.GetInt32(this.tokDataPos)); return money.ToString(); } case BinXmlToken.XSD_BINHEX: return BinHexEncoder.Encode(this.data, this.tokDataPos, this.tokLen); case BinXmlToken.XSD_BOOLEAN: if (this.data[this.tokDataPos] != 0) { return "true"; } return "false"; case BinXmlToken.XSD_UNSIGNEDLONG: return this.ValueAsULong().ToString(CultureInfo.InvariantCulture); case BinXmlToken.XSD_QNAME: num8 = this.ParseMB32(this.tokDataPos); if ((num8 < 0) || (num8 >= this.symbolTables.qnameCount)) { throw new XmlException("XmlBin_InvalidQNameID", string.Empty); } break; default: throw this.ThrowUnexpectedToken(this.token); } QName name = this.symbolTables.qnametable[num8]; if (name.prefix.Length == 0) { return name.localname; } return (name.prefix + ":" + name.localname); } catch { this.state = ScanState.Error; throw; } return str; }
private object ValueAsObject(BinXmlToken token, bool returnInternalTypes) { this.CheckValueTokenBounds(); switch (token) { case BinXmlToken.SQL_SMALLINT: return this.GetInt16(this.tokDataPos); case BinXmlToken.SQL_INT: return this.GetInt32(this.tokDataPos); case BinXmlToken.SQL_REAL: return this.GetSingle(this.tokDataPos); case BinXmlToken.SQL_FLOAT: return this.GetDouble(this.tokDataPos); case BinXmlToken.SQL_MONEY: { BinXmlSqlMoney money2 = new BinXmlSqlMoney(this.GetInt64(this.tokDataPos)); if (!returnInternalTypes) { return money2.ToDecimal(); } return money2; } case BinXmlToken.SQL_BIT: return (int) this.data[this.tokDataPos]; case BinXmlToken.SQL_TINYINT: return this.data[this.tokDataPos]; case BinXmlToken.SQL_BIGINT: return this.GetInt64(this.tokDataPos); case BinXmlToken.SQL_UUID: { int tokDataPos = this.tokDataPos; int a = this.GetInt32(tokDataPos); short b = this.GetInt16(tokDataPos + 4); short c = this.GetInt16(tokDataPos + 6); Guid guid = new Guid(a, b, c, this.data[tokDataPos + 8], this.data[tokDataPos + 9], this.data[tokDataPos + 10], this.data[tokDataPos + 11], this.data[tokDataPos + 12], this.data[tokDataPos + 13], this.data[tokDataPos + 14], this.data[tokDataPos + 15]); return guid.ToString(); } case BinXmlToken.SQL_DECIMAL: case BinXmlToken.SQL_NUMERIC: case BinXmlToken.XSD_DECIMAL: { BinXmlSqlDecimal num6 = new BinXmlSqlDecimal(this.data, this.tokDataPos, token == BinXmlToken.XSD_DECIMAL); if (returnInternalTypes) { return num6; } return num6.ToDecimal(); } case BinXmlToken.SQL_BINARY: case BinXmlToken.SQL_VARBINARY: case BinXmlToken.SQL_IMAGE: case BinXmlToken.SQL_UDT: case BinXmlToken.XSD_BINHEX: case BinXmlToken.XSD_BASE64: { byte[] destinationArray = new byte[this.tokLen]; Array.Copy(this.data, this.tokDataPos, destinationArray, 0, this.tokLen); return destinationArray; } case BinXmlToken.SQL_CHAR: case BinXmlToken.SQL_VARCHAR: case BinXmlToken.SQL_TEXT: { int pos = this.tokDataPos; return Encoding.GetEncoding(this.GetInt32(pos)).GetString(this.data, pos + 4, this.tokLen - 4); } case BinXmlToken.SQL_NCHAR: case BinXmlToken.SQL_NVARCHAR: case BinXmlToken.SQL_NTEXT: return this.GetString(this.tokDataPos, this.tokLen); case BinXmlToken.SQL_DATETIME: case BinXmlToken.SQL_SMALLDATETIME: case BinXmlToken.XSD_KATMAI_TIME: case BinXmlToken.XSD_KATMAI_DATETIME: case BinXmlToken.XSD_KATMAI_DATE: case BinXmlToken.XSD_TIME: case BinXmlToken.XSD_DATETIME: case BinXmlToken.XSD_DATE: return this.ValueAsDateTime(); case BinXmlToken.SQL_SMALLMONEY: { BinXmlSqlMoney money = new BinXmlSqlMoney(this.GetInt32(this.tokDataPos)); if (!returnInternalTypes) { return money.ToDecimal(); } return money; } case BinXmlToken.XSD_KATMAI_TIMEOFFSET: case BinXmlToken.XSD_KATMAI_DATETIMEOFFSET: case BinXmlToken.XSD_KATMAI_DATEOFFSET: return this.ValueAsDateTimeOffset(); case BinXmlToken.XSD_BOOLEAN: return (0 != this.data[this.tokDataPos]); case BinXmlToken.XSD_BYTE: return (sbyte) this.data[this.tokDataPos]; case BinXmlToken.XSD_UNSIGNEDSHORT: return this.GetUInt16(this.tokDataPos); case BinXmlToken.XSD_UNSIGNEDINT: return this.GetUInt32(this.tokDataPos); case BinXmlToken.XSD_UNSIGNEDLONG: return this.GetUInt64(this.tokDataPos); case BinXmlToken.XSD_QNAME: { int index = this.ParseMB32(this.tokDataPos); if ((index < 0) || (index >= this.symbolTables.qnameCount)) { throw new XmlException("XmlBin_InvalidQNameID", string.Empty); } QName name = this.symbolTables.qnametable[index]; return new XmlQualifiedName(name.localname, name.namespaceUri); } } throw this.ThrowUnexpectedToken(this.token); }
private decimal ValueAsDecimal() { this.CheckValueTokenBounds(); switch (this.token) { case BinXmlToken.SQL_SMALLINT: case BinXmlToken.SQL_INT: case BinXmlToken.SQL_BIT: case BinXmlToken.SQL_TINYINT: case BinXmlToken.SQL_BIGINT: case BinXmlToken.XSD_BYTE: case BinXmlToken.XSD_UNSIGNEDSHORT: case BinXmlToken.XSD_UNSIGNEDINT: return new decimal(this.ValueAsLong()); case BinXmlToken.SQL_REAL: return new decimal(this.GetSingle(this.tokDataPos)); case BinXmlToken.SQL_FLOAT: return new decimal(this.GetDouble(this.tokDataPos)); case BinXmlToken.SQL_MONEY: { BinXmlSqlMoney money2 = new BinXmlSqlMoney(this.GetInt64(this.tokDataPos)); return money2.ToDecimal(); } case BinXmlToken.SQL_DECIMAL: case BinXmlToken.SQL_NUMERIC: case BinXmlToken.XSD_DECIMAL: { BinXmlSqlDecimal num = new BinXmlSqlDecimal(this.data, this.tokDataPos, this.token == BinXmlToken.XSD_DECIMAL); return num.ToDecimal(); } case BinXmlToken.SQL_SMALLMONEY: { BinXmlSqlMoney money = new BinXmlSqlMoney(this.GetInt32(this.tokDataPos)); return money.ToDecimal(); } case BinXmlToken.XSD_UNSIGNEDLONG: return new decimal(this.ValueAsULong()); } throw this.ThrowUnexpectedToken(this.token); }
private object ValueAs(BinXmlToken token, Type returnType, IXmlNamespaceResolver namespaceResolver) { this.CheckValueTokenBounds(); switch (token) { case BinXmlToken.SQL_SMALLINT: { int num = this.GetInt16(this.tokDataPos); return this.GetValueConverter(XmlTypeCode.Short).ChangeType(num, returnType, namespaceResolver); } case BinXmlToken.SQL_INT: { int num2 = this.GetInt32(this.tokDataPos); return this.GetValueConverter(XmlTypeCode.Int).ChangeType(num2, returnType, namespaceResolver); } case BinXmlToken.SQL_REAL: { float single = this.GetSingle(this.tokDataPos); return this.GetValueConverter(XmlTypeCode.Float).ChangeType(single, returnType, namespaceResolver); } case BinXmlToken.SQL_FLOAT: { double num8 = this.GetDouble(this.tokDataPos); return this.GetValueConverter(XmlTypeCode.Double).ChangeType(num8, returnType, namespaceResolver); } case BinXmlToken.SQL_MONEY: { BinXmlSqlMoney money2 = new BinXmlSqlMoney(this.GetInt64(this.tokDataPos)); return this.GetValueConverter(XmlTypeCode.Decimal).ChangeType(money2.ToDecimal(), returnType, namespaceResolver); } case BinXmlToken.SQL_BIT: return this.GetValueConverter(XmlTypeCode.NonNegativeInteger).ChangeType((int) this.data[this.tokDataPos], returnType, namespaceResolver); case BinXmlToken.SQL_TINYINT: return this.GetValueConverter(XmlTypeCode.UnsignedByte).ChangeType(this.data[this.tokDataPos], returnType, namespaceResolver); case BinXmlToken.SQL_BIGINT: { long num3 = this.GetInt64(this.tokDataPos); return this.GetValueConverter(XmlTypeCode.Long).ChangeType(num3, returnType, namespaceResolver); } case BinXmlToken.SQL_UUID: return this.GetValueConverter(XmlTypeCode.String).ChangeType(this.ValueAsString(token), returnType, namespaceResolver); case BinXmlToken.SQL_DECIMAL: case BinXmlToken.SQL_NUMERIC: case BinXmlToken.XSD_DECIMAL: { BinXmlSqlDecimal num12 = new BinXmlSqlDecimal(this.data, this.tokDataPos, token == BinXmlToken.XSD_DECIMAL); return this.GetValueConverter(XmlTypeCode.Decimal).ChangeType(num12.ToDecimal(), returnType, namespaceResolver); } case BinXmlToken.SQL_BINARY: case BinXmlToken.SQL_VARBINARY: case BinXmlToken.SQL_IMAGE: case BinXmlToken.SQL_UDT: case BinXmlToken.XSD_BINHEX: case BinXmlToken.XSD_BASE64: { byte[] destinationArray = new byte[this.tokLen]; Array.Copy(this.data, this.tokDataPos, destinationArray, 0, this.tokLen); return this.GetValueConverter((token == BinXmlToken.XSD_BINHEX) ? XmlTypeCode.HexBinary : XmlTypeCode.Base64Binary).ChangeType(destinationArray, returnType, namespaceResolver); } case BinXmlToken.SQL_CHAR: case BinXmlToken.SQL_VARCHAR: case BinXmlToken.SQL_TEXT: { int tokDataPos = this.tokDataPos; Encoding encoding = Encoding.GetEncoding(this.GetInt32(tokDataPos)); return this.GetValueConverter(XmlTypeCode.UntypedAtomic).ChangeType(encoding.GetString(this.data, tokDataPos + 4, this.tokLen - 4), returnType, namespaceResolver); } case BinXmlToken.SQL_NCHAR: case BinXmlToken.SQL_NVARCHAR: case BinXmlToken.SQL_NTEXT: return this.GetValueConverter(XmlTypeCode.UntypedAtomic).ChangeType(this.GetString(this.tokDataPos, this.tokLen), returnType, namespaceResolver); case BinXmlToken.SQL_DATETIME: case BinXmlToken.SQL_SMALLDATETIME: case BinXmlToken.XSD_KATMAI_TIME: case BinXmlToken.XSD_KATMAI_DATETIME: case BinXmlToken.XSD_KATMAI_DATE: case BinXmlToken.XSD_DATETIME: return this.GetValueConverter(XmlTypeCode.DateTime).ChangeType(this.ValueAsDateTime(), returnType, namespaceResolver); case BinXmlToken.SQL_SMALLMONEY: { BinXmlSqlMoney money = new BinXmlSqlMoney(this.GetInt32(this.tokDataPos)); return this.GetValueConverter(XmlTypeCode.Decimal).ChangeType(money.ToDecimal(), returnType, namespaceResolver); } case BinXmlToken.XSD_KATMAI_TIMEOFFSET: case BinXmlToken.XSD_KATMAI_DATETIMEOFFSET: case BinXmlToken.XSD_KATMAI_DATEOFFSET: return this.GetValueConverter(XmlTypeCode.DateTime).ChangeType(this.ValueAsDateTimeOffset(), returnType, namespaceResolver); case BinXmlToken.XSD_TIME: return this.GetValueConverter(XmlTypeCode.Time).ChangeType(this.ValueAsDateTime(), returnType, namespaceResolver); case BinXmlToken.XSD_DATE: return this.GetValueConverter(XmlTypeCode.Date).ChangeType(this.ValueAsDateTime(), returnType, namespaceResolver); case BinXmlToken.XSD_BOOLEAN: return this.GetValueConverter(XmlTypeCode.Boolean).ChangeType(0 != this.data[this.tokDataPos], returnType, namespaceResolver); case BinXmlToken.XSD_BYTE: return this.GetValueConverter(XmlTypeCode.Byte).ChangeType((int) ((sbyte) this.data[this.tokDataPos]), returnType, namespaceResolver); case BinXmlToken.XSD_UNSIGNEDSHORT: { int num4 = this.GetUInt16(this.tokDataPos); return this.GetValueConverter(XmlTypeCode.UnsignedShort).ChangeType(num4, returnType, namespaceResolver); } case BinXmlToken.XSD_UNSIGNEDINT: { long num5 = this.GetUInt32(this.tokDataPos); return this.GetValueConverter(XmlTypeCode.UnsignedInt).ChangeType(num5, returnType, namespaceResolver); } case BinXmlToken.XSD_UNSIGNEDLONG: { decimal num6 = this.GetUInt64(this.tokDataPos); return this.GetValueConverter(XmlTypeCode.UnsignedLong).ChangeType(num6, returnType, namespaceResolver); } case BinXmlToken.XSD_QNAME: { int index = this.ParseMB32(this.tokDataPos); if ((index < 0) || (index >= this.symbolTables.qnameCount)) { throw new XmlException("XmlBin_InvalidQNameID", string.Empty); } QName name = this.symbolTables.qnametable[index]; return this.GetValueConverter(XmlTypeCode.QName).ChangeType(new XmlQualifiedName(name.localname, name.namespaceUri), returnType, namespaceResolver); } } throw this.ThrowUnexpectedToken(this.token); }