예제 #1
0
파일: Serializer.cs 프로젝트: mmvlad/ecs
        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);
        }
예제 #2
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);
        }
예제 #3
0
파일: Serializer.cs 프로젝트: mmvlad/ecs
        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);
        }
예제 #4
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);
        }