Пример #1
0
        public static void WriteValueString(WritableBuffer buffer, string value, HeaderOptions options)
        {
            switch (options & HeaderOptions.ValueCompressionMask)
            {
            case HeaderOptions.ValueCompressionAutomatic:
                var len = HuffmanCode.GetByteCount(value);
                if (len < value.Length)
                {
                    WriteUInt32(buffer, (uint)len, 0x80, 7);
                    HuffmanCode.Write(buffer, value);
                }
                else
                {
                    WriteUInt32(buffer, (uint)value.Length, 0, 7);
                    buffer.WriteAsciiString(value);
                }
                break;

            case HeaderOptions.ValueCompressionOn:
                len = HuffmanCode.GetByteCount(value);
                WriteUInt32(buffer, (uint)len, 0x80, 7);
                HuffmanCode.Write(buffer, value);
                break;

            case HeaderOptions.ValueCompressionOff:
                WriteUInt32(buffer, (uint)value.Length, 0, 7);
                buffer.WriteAsciiString(value);
                break;

            default:
                throw new InvalidOperationException("Invalid value compression: " + options);
            }
        }
 private static void WriteHeaders(HttpHeaders headers, ref WritableBuffer buffer)
 {
     foreach (var header in headers)
     {
         buffer.WriteAsciiString($"{header.Key}:{string.Join(",", header.Value)}\r\n");
     }
 }
 public void WriteMessage(ref WritableBuffer buffer)
 {
     buffer.WriteBigEndian(Bid1);
     buffer.WriteBigEndian(Bid2);
     buffer.WriteBigEndian(Bid3);
     buffer.WriteBigEndian(Bid4);
     buffer.WriteBigEndian(Ask1);
     buffer.WriteBigEndian(Ask2);
     buffer.WriteBigEndian(Ask3);
     buffer.WriteBigEndian(Ask4);
     buffer.WriteBigEndian(Size1);
     buffer.WriteBigEndian(Size2);
     buffer.WriteBigEndian(Size3);
     buffer.WriteBigEndian(Size4);
     buffer.WriteAsciiString(SecurityCode);
     buffer.WriteLittleEndian(0x00);
 }