Exemplo n.º 1
0
 public SpanContext(TraceID TraceID = default, SpanID SpanID = default)
 {
     this.TraceID = TraceID;
     this.SpanID  = SpanID;
 }
Exemplo n.º 2
0
Arquivo: id.cs Projeto: zjmit/go2cs
 public static @string String(this TraceID t)
 {
     return(fmt.Sprintf("%02x", t[..]));
        public void Pack(MemoryStream stream)
        {
            if (Options.Count == 0 || Options[0].Type != TDSPreLoginOptionTokenType.Version || Options[Options.Count - 1].Type != TDSPreLoginOptionTokenType.Terminator || !Terminated)
            {
                throw new InvalidOperationException();
            }

            var offset = (ushort)((Options.Count - 1) * (2 * sizeof(ushort) + sizeof(byte)) + sizeof(byte));

            foreach (var option in Options)
            {
                // ToDo
                option.Offset = offset;
                option.Pack(stream);
            }

            foreach (var option in Options)
            {
                switch (option.Type)
                {
                case TDSPreLoginOptionTokenType.Encryption:
                {
                    stream.WriteByte((byte)Encryption);
                    break;
                }

                case TDSPreLoginOptionTokenType.FedAuthRequired:
                {
                    if (FedAuthRequired)
                    {
                        stream.WriteByte(0x01);
                    }
                    else
                    {
                        stream.WriteByte(0x00);
                    }
                    break;
                }

                case TDSPreLoginOptionTokenType.InstOpt:
                {
                    throw new NotSupportedException();
                }

                case TDSPreLoginOptionTokenType.MARS:
                {
                    if (MARS)
                    {
                        stream.WriteByte(0x01);
                    }
                    else
                    {
                        stream.WriteByte(0x00);
                    }
                    break;
                }

                case TDSPreLoginOptionTokenType.NonceOpt:
                {
                    BigEndianUtilities.WriteByteArray(stream, Nonce);
                    break;
                }

                case TDSPreLoginOptionTokenType.ThreadID:
                {
                    BigEndianUtilities.WriteULong(stream, ThreadID);
                    break;
                }

                case TDSPreLoginOptionTokenType.TraceID:
                {
                    TraceID.Pack(stream);
                    break;
                }

                case TDSPreLoginOptionTokenType.Version:
                {
                    ClientVersion.Pack(stream);
                    break;
                }
                }
            }
        }