Пример #1
0
    public byte[] Pack()
    {
        stream = new MemoryStream();
        if (transport == null)
        {
            transport = new TStreamTransport(null, stream);
        }
        else
        {
            transport.OutputStream = stream;
        }

        if (protocol == null)
        {
            protocol = new TCompactProtocol(transport);
        }
        else
        {
            protocol.reset();
            protocol.Transport = transport;
        }

        protocol.WriteStructBegin(struc);

        fieldWriter.Name = "context";
        fieldWriter.Type = TType.Map;
        fieldWriter.ID   = 1;
        protocol.WriteFieldBegin(fieldWriter);
        {
            protocol.WriteMapBegin(new TMap(TType.String, TType.Struct, context.Count));
            foreach (string _iter44 in context.Keys)
            {
                protocol.WriteString(_iter44);
                context[_iter44].Write(fieldWriter, protocol);
            }
            protocol.WriteMapEnd();
        }
        protocol.WriteFieldEnd();

        fieldWriter.Name = "events";
        fieldWriter.Type = TType.Map;
        fieldWriter.ID   = 2;
        protocol.WriteFieldBegin(fieldWriter);
        {
            protocol.WriteMapBegin(new TMap(TType.String, TType.Struct, events.Count));
            foreach (string _iter44 in events.Keys)
            {
                protocol.WriteString(_iter44);
                events[_iter44].Write(fieldWriter, protocol);
            }
            protocol.WriteMapEnd();
        }
        protocol.WriteFieldEnd();

        protocol.WriteFieldStop();
        protocol.WriteStructEnd();

        return(stream.ToArray());
    }