Beispiel #1
0
 public bool Unpack(MemoryStream stream)
 {
     TraceID          = BigEndianUtilities.ReadByteArray(stream, 16);
     ActivityID       = BigEndianUtilities.ReadByteArray(stream, 16);
     ActivitySequence = BigEndianUtilities.ReadULong(stream);
     return(true);
 }
Beispiel #2
0
        public void ReadULongFromMemoryStream()
        {
            var stream = new MemoryStream();

            stream.Write(new byte[] { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef });
            stream.Seek(0, SeekOrigin.Begin);

            var res = BigEndianUtilities.ReadULong(stream);

            Assert.AreEqual((ulong)0x0123456789abcdef, res);
        }
        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);
        }