public static byte[] SerializeDictionary <TK, TV>(this IDictionary <TK, TV> dictionary) where TK : struct where TV : struct { using var writer = new PoolByteWriter(); writer.WriteInt(dictionary.Count); foreach ((TK key, TV value) in dictionary) { writer.Write <TK>(key); writer.Write <TV>(value); } return(writer.ToArray()); }
public static byte[] Serialize <T>(this T value) where T : IByteSerializable { using var writer = new PoolByteWriter(); writer.WriteClass <T>(value); return(writer.ToArray()); }
public static byte[] SerializeCollection <T>(this ICollection <T> collection) where T : struct { using var writer = new PoolByteWriter(); writer.WriteCollection(collection); return(writer.ToArray()); }