public bool Unpack(MemoryStream stream) { { TDSPreLoginOptionToken option; do { option = new TDSPreLoginOptionToken(); option.Unpack(stream); Options.Add(option); }while (option.Type != TDSPreLoginOptionTokenType.Terminator); } foreach (var option in Options) { switch (option.Type) { case TDSPreLoginOptionTokenType.Encryption: { Encryption = (TDSEncryptionOption)stream.ReadByte(); break; } case TDSPreLoginOptionTokenType.FedAuthRequired: { FedAuthRequired = stream.ReadByte() == 1; break; } case TDSPreLoginOptionTokenType.InstOpt: { throw new NotSupportedException(); } case TDSPreLoginOptionTokenType.MARS: { MARS = stream.ReadByte() == 1; break; } case TDSPreLoginOptionTokenType.NonceOpt: { Nonce = BigEndianUtilities.ReadByteArray(stream, 32); break; } case TDSPreLoginOptionTokenType.ThreadID: { ThreadID = BigEndianUtilities.ReadULong(stream); break; } case TDSPreLoginOptionTokenType.TraceID: { TraceID = new TDSClientTraceID(); TraceID.Unpack(stream); break; } case TDSPreLoginOptionTokenType.Version: { ClientVersion = new TDSClientVersion(); ClientVersion.Unpack(stream); break; } case TDSPreLoginOptionTokenType.Terminator: { break; } } } Terminated = true; return(true); }
/// <summary> /// Used to unpack IPackageable from a stream. /// </summary> /// <param name="stream">MemoryStream from which to unpack IPackageable.</param> /// <returns>Returns true if successful.</returns> public bool Unpack(MemoryStream stream) { { TDSPreLoginOptionToken option; do { option = new TDSPreLoginOptionToken(); option.Unpack(stream); this.Options.Add(option); }while (option.Type != TDSPreLoginOptionTokenType.Terminator); } foreach (var option in this.Options) { switch (option.Type) { case TDSPreLoginOptionTokenType.Encryption: { this.Encryption = (TDSEncryptionOption)stream.ReadByte(); break; } case TDSPreLoginOptionTokenType.FedAuthRequired: { this.FedAuthRequired = stream.ReadByte() == 1; break; } case TDSPreLoginOptionTokenType.InstOpt: { this.Instance = new byte[option.Length]; stream.Read(this.Instance, 0, option.Length); break; } case TDSPreLoginOptionTokenType.MARS: { this.MARS = stream.ReadByte() == 1; break; } case TDSPreLoginOptionTokenType.NonceOpt: { this.Nonce = BigEndianUtilities.ReadByteArray(stream, 32); break; } case TDSPreLoginOptionTokenType.ThreadID: { this.ThreadID = BigEndianUtilities.ReadUInt(stream); break; } case TDSPreLoginOptionTokenType.TraceID: { this.TraceID = new TDSClientTraceID(); this.TraceID.Unpack(stream); break; } case TDSPreLoginOptionTokenType.Version: { this.ClientVersion = new TDSClientVersion(); this.ClientVersion.Unpack(stream); break; } case TDSPreLoginOptionTokenType.Terminator: { break; } } } this.Terminated = true; return(true); }