Exemplo n.º 1
0
        public static void WriteInt(this Stream stream, int data)
        {
            Span <byte> buffer = stackalloc byte[sizeof(int)];

            if (BitConverter20.TryWriteBytes(buffer, data))
            {
                stream.Write(buffer);
            }
        }
Exemplo n.º 2
0
        public static void WriteByteFromStack(this Stream stream, byte data)
        {
            Span <byte> buffer = stackalloc byte[sizeof(ushort)];

            if (BitConverter20.TryWriteBytes(buffer, data))
            {
                stream.Write(buffer.Slice(0, 1));
            }
        }
Exemplo n.º 3
0
        public static void WriteUlong(this Stream stream, ulong data)
        {
            Span <byte> buffer = stackalloc byte[sizeof(ulong)];

            if (BitConverter20.TryWriteBytes(buffer, data))
            {
                stream.Write(buffer);
            }
        }
Exemplo n.º 4
0
        public static void WriteLong(this Stream stream, long data)
        {
            var         memStream = new MemoryStream();
            Span <byte> buffer    = stackalloc byte[sizeof(long)];

            if (BitConverter20.TryWriteBytes(buffer, data))
            {
                stream.Write(buffer);
            }
        }