コード例 #1
0
        public int WriteTo(Memory <byte> memory, ulong bodySize)
        {
            NetworkOrderSerializer.WriteUInt16(memory, ZERO); // Weight - not used
            NetworkOrderSerializer.WriteUInt64(memory.Slice(2), bodySize);

            ContentHeaderPropertyWriter writer = new ContentHeaderPropertyWriter(memory.Slice(10));

            WritePropertiesTo(ref writer);
            return(10 + writer.Offset);
        }
コード例 #2
0
            public static int WriteTo(Span <byte> span, ushort channel, ContentHeaderBase header, int bodyLength)
            {
                const int StartClassId         = StartPayload;
                const int StartWeight          = StartPayload + 2;
                const int StartBodyLength      = StartPayload + 4;
                const int StartHeaderArguments = StartPayload + 12;

                NetworkOrderSerializer.WriteUInt16(span.Slice(StartClassId), header.ProtocolClassId);
                NetworkOrderSerializer.WriteUInt16(span.Slice(StartWeight), 0); // Weight - not used
                NetworkOrderSerializer.WriteUInt64(span.Slice(StartBodyLength), (ulong)bodyLength);
                var headerWriter = new ContentHeaderPropertyWriter(span.Slice(StartHeaderArguments));

                header.WritePropertiesTo(ref headerWriter);
                return(WriteBaseFrame(span, FrameType.FrameHeader, channel, StartHeaderArguments - StartPayload + headerWriter.Offset));
            }
コード例 #3
0
 public void Check(ContentHeaderPropertyWriter w, byte[] expected)
 {
     byte[] actual = Contents(w);
     try
     {
         Assert.AreEqual(expected, actual);
     }
     catch
     {
         Console.WriteLine();
         Console.WriteLine("EXPECTED ==================================================");
         DebugUtil.Dump(expected);
         Console.WriteLine("ACTUAL ====================================================");
         DebugUtil.Dump(actual);
         Console.WriteLine("===========================================================");
         throw;
     }
 }
コード例 #4
0
 public abstract void WritePropertiesTo(ContentHeaderPropertyWriter writer);
コード例 #5
0
 public abstract void WritePropertiesTo(ContentHeaderPropertyWriter writer);
コード例 #6
0
 internal abstract void WritePropertiesTo(ref ContentHeaderPropertyWriter writer);
コード例 #7
0
 public byte[] Contents(ContentHeaderPropertyWriter w)
 {
     return ((MemoryStream)w.BaseWriter.BaseStream).ToArray();
 }
コード例 #8
0
 public void SetUp()
 {
     m_w = Writer();
 }