Example #1
0
        private void Encode(Span <byte> memory)
        {
            var writer = new BinarySpanWriter(memory, ByteOrder.LittleEndian);

            writer.Write(EndPoint.Utf8EncodedValue.Span, lengthPrefix: true);
            writer.Write(Module.Name.AsSpan(), lengthPrefix: true);
            writer.WriteInt32(Version.MajorVersion);
            writer.WriteInt32(Version.MinorVersion);
            writer.WriteInt32(Version.Revision);
            writer.WriteBool(Version.IsPreRelease);

            Assert(memory.Length == writer.Length);
        }
        private int EncodePayload(Span <byte> span, ReadOnlySpan <char> securityToken, DateTime leaseEnd)
        {
            var writer = new BinarySpanWriter(span);

            writer.Write(securityToken, lengthPrefix: true);
            writer.WriteInt64(leaseEnd.Ticks);

            return(writer.Length);
        }