Class BinaryWrapperSerializer
Base for data formats that wrap bytes rather than serialize an object model (Base64, GZip, Zip).
Marshal accepts a byte[], a string (UTF-8) or a ;
Unmarshal yields byte[], string, or object (bytes).
Anything else is an error that names the format, not a NullReferenceException later.
public abstract class BinaryWrapperSerializer : IMessageSerializer
Inheritance
Implements
Derived
Properties
ContentType
Content type this serializer handles (e.g., "application/json").
public abstract string ContentType { get; }
MediaTypes
All media types this serializer can handle, including structured-suffix aliases
public virtual IReadOnlyCollection<string> MediaTypes { get; }
WrapsBytes
true for a format whose input is raw bytes rather than an object model (Base64, GZip, Zip):
public bool WrapsBytes { get; }
Methods
Deserialize(byte[], Type)
Deserializes a byte array to a typed value.
public object? Deserialize(byte[] data, Type type)
Deserialize<T>(byte[])
Deserializes a byte array to a typed value.
public T? Deserialize<T>(byte[] data)
Encode(byte[])
Wraps the payload (encode / compress).
protected abstract byte[] Encode(byte[] payload)
ReadBounded(Stream, long, string)
Copies the decoded source into a buffer, refusing to grow past
protected static byte[] ReadBounded(Stream source, long limit, string formatName)