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); }
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)); }
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; } }
public abstract void WritePropertiesTo(ContentHeaderPropertyWriter writer);
internal abstract void WritePropertiesTo(ref ContentHeaderPropertyWriter writer);
public byte[] Contents(ContentHeaderPropertyWriter w) { return ((MemoryStream)w.BaseWriter.BaseStream).ToArray(); }
public void SetUp() { m_w = Writer(); }