예제 #1
0
        public static void Encode(Stream stream, BObject obj, string prefix = null)
        {
            if (prefix is not null)
            {
                stream.Write(Encoding.UTF8.GetBytes(prefix));
            }
            stream.WriteByte(0);

            EncodeNoPrefix(stream, obj);
        }
예제 #2
0
 public static ValueTask EncodeAsync(Stream stream, BObject obj, string prefix = null, CancellationToken cancellationToken = default)
 {
     return(stream.WriteAsync(Encode(obj, prefix), cancellationToken));
 }
예제 #3
0
 public static byte[] EncodeNoPrefix(BObject obj)
 {
     using var mem = new MemoryStream(1500);
     EncodeNoPrefix(mem, obj);
     return(mem.ToArray());
 }
예제 #4
0
 public static void EncodeNoPrefix(Stream stream, BObject obj)
 {
     obj.Write(stream);
 }
예제 #5
0
 public static byte[] Encode(BObject obj, string prefix = null)
 {
     using var mem = new MemoryStream(1500);
     Encode(mem, obj, prefix);
     return(mem.ToArray());
 }
예제 #6
0
 public static ValueTask EncodeNoPrefixAsync(Stream stream, BObject obj, CancellationToken cancellationToken = default)
 {
     return(stream.WriteAsync(EncodeNoPrefix(obj), cancellationToken));
 }