Esempio n. 1
0
        public static T Unpack <T>(Serializers allSerializers, byte[] bytes)
        {
            var packer = Serializer.SetupDefaultPacker(allSerializers, bytes);

            var serializer = new GenericSerializer();
            var instance   = (T)serializer.Unpack(packer, typeof(T));

            return(instance);
        }
Esempio n. 2
0
        public static T UnpackStatic <T>(byte[] bytes, Serializers staticSerializers)
        {
            var packer = Serializer.SetupDefaultPacker(staticSerializers, bytes);

            var serializer = new GenericSerializer();
            var result     = (T)serializer.Unpack(packer, typeof(T));

            packer.Dispose();
            return(result);
        }
Esempio n. 3
0
        public static T Unpack <T>(byte[] bytes, Serializers customSerializers)
        {
            var packer = Serializer.SetupDefaultPacker(bytes, customSerializers);

            var serializer = new GenericSerializer();
            var instance   = (T)serializer.Unpack(packer, typeof(T));

            customSerializers.Dispose();
            packer.serializers.Dispose();
            return(instance);
        }
Esempio n. 4
0
        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);
        }
Esempio n. 5
0
        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);
        }
Esempio n. 6
0
        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);
        }
Esempio n. 7
0
        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);
        }