public static byte[] Pack <T>(Serializers allSerializers, T obj) { byte[] bytes = null; var packer = new Packer(allSerializers, new System.IO.MemoryStream()); var serializer = new GenericSerializer(); serializer.Pack(packer, obj, typeof(T)); bytes = packer.ToArray(); return(bytes); }
public static byte[] PackStatic <T>(T obj, Serializers staticSerializers) { var packer = new Packer(staticSerializers, new System.IO.MemoryStream(Serializer.BUFFER_CAPACITY)); var serializer = new GenericSerializer(); serializer.Pack(packer, obj, typeof(T)); var result = packer.ToArray(); packer.Dispose(); return(result); }
public static byte[] Pack <T>(T obj, Serializers customSerializers) { var serializersInternal = Serializer.GetInternalSerializers(); var serializers = Serializer.GetDefaultSerializers(); serializers.Add(serializersInternal); serializers.Add(customSerializers); byte[] bytes = null; var packer = new Packer(serializers, new System.IO.MemoryStream()); var serializer = new GenericSerializer(); serializer.Pack(packer, obj, typeof(T)); bytes = packer.ToArray(); return(bytes); }
public static byte[] Pack <T>(T obj, System.Type type, Serializers customSerializers) { var serializersInternal = Serializer.GetInternalSerializers(); var serializers = Serializer.GetDefaultSerializers(); serializers.Add(ref serializersInternal); serializers.Add(ref customSerializers); serializersInternal.Dispose(); customSerializers.Dispose(); var packer = new Packer(serializers, new System.IO.MemoryStream(Serializer.BUFFER_CAPACITY)); var serializer = new GenericSerializer(); serializer.Pack(packer, obj, type); var bytes = packer.ToArray(); serializers.Dispose(); packer.Dispose(); return(bytes); }