Esempio n. 1
0
        // Test Initialize:)
        public void _Init()
        {
            // ZeroFormatter Prepare
            ZeroFormatter.Formatters.Formatter.RegisterList <Person>();

            // MsgPack Prepare
            MsgPack.Serialization.MessagePackSerializer.PrepareType <Sex>();
            this.msgPackContext = new MsgPack.Serialization.SerializationContext();
            this.msgPackContext.ResolveSerializer += SerializationContext_ResolveSerializer;

            this.p = new Person
            {
                Age       = 99999,
                FirstName = "Windows",
                LastName  = "Server",
                Sex       = Sex.Male,
            };
            this.p2 = new PersonLike
            {
                Age       = 99999,
                FirstName = "Windows",
                LastName  = "Server",
                Sex       = Sex2.Male
            };

            this.l = Enumerable.Range(1000, 1000).Select(x => new Person {
                Age = x, FirstName = "Windows", LastName = "Server", Sex = Sex.Female
            }).ToArray();
            this.l2 = new PersonLikeVector {
                List = Enumerable.Range(1000, 1000).Select(x => new PersonLike {
                    Age = x, FirstName = "Windows", LastName = "Server", Sex = Sex2.Female
                }).ToArray()
            };

            zeroFormatterSingleBytes = ZeroFormatterSerializer.Serialize(p);
            zeroFormatterArrayBytes  = ZeroFormatterSerializer.Serialize(l);
            var serializer1 = this.msgPackContext.GetSerializer <Person>();

            msgpackSingleBytes = serializer1.PackSingleObject(p);
            var serializer2 = this.msgPackContext.GetSerializer <IList <Person> >();

            msgpackArrayBytes = serializer2.PackSingleObject(l);

            jsonSingleBytes = Encoding.UTF8.GetBytes(JsonUtility.ToJson(p2));
            jsonArrayBytes  = Encoding.UTF8.GetBytes(JsonUtility.ToJson(l2));
        }
Esempio n. 2
0
        // Test Initialize:)
        public void _Init()
        {
            // ZeroFormatter Prepare
            ZeroFormatter.Formatters.Formatter.RegisterList <Person>();

            // MsgPack Prepare
            MsgPack.Serialization.MessagePackSerializer.PrepareType <Sex>();
            this.msgPackContext = new MsgPack.Serialization.SerializationContext();
            this.msgPackContext.ResolveSerializer += SerializationContext_ResolveSerializer;

            this.p = new Person
            {
                Age       = 99999,
                FirstName = "Windows",
                LastName  = "Server",
                Sex       = Sex.Male,
            };
            this.p2 = new PersonLike
            {
                Age       = 99999,
                FirstName = "Windows",
                LastName  = "Server",
                Sex       = Sex2.Male
            };

            this.l = Enumerable.Range(1000, 1000).Select(x => new Person {
                Age = x, FirstName = "Windows", LastName = "Server", Sex = Sex.Female
            }).ToArray();
            this.l2 = new PersonLikeVector {
                List = Enumerable.Range(1000, 1000).Select(x => new PersonLike {
                    Age = x, FirstName = "Windows", LastName = "Server", Sex = Sex2.Female
                }).ToArray()
            };

            zeroFormatterSingleBytes = ZeroFormatterSerializer.Serialize(p);
            zeroFormatterArrayBytes  = ZeroFormatterSerializer.Serialize(l);
            var serializer1 = this.msgPackContext.GetSerializer <Person>();

            msgpackSingleBytes = serializer1.PackSingleObject(p);
            var serializer2 = this.msgPackContext.GetSerializer <IList <Person> >();

            msgpackArrayBytes = serializer2.PackSingleObject(l);

            jsonSingleBytes = Encoding.UTF8.GetBytes(JsonUtility.ToJson(p2));
            jsonArrayBytes  = Encoding.UTF8.GetBytes(JsonUtility.ToJson(l2));

            // vector?

            //MsgPack.Serialization.MessagePackSerializer.PrepareType<Vector3>();
            //MsgPack.Serialization.MessagePackSerializer.PrepareType<Vector3[]>();

            //v3 = new Vector3 { x = 12345.12345f, y = 3994.35226f, z = 325125.52426f };
            //v3Array = Enumerable.Range(1, 100).Select(_ => new Vector3 { x = 12345.12345f, y = 3994.35226f, z = 325125.52426f }).ToArray();
            //zeroFormatterv3Bytes = ZeroFormatterSerializer.Serialize(v3);
            //zeroFormatterv3ArrayBytes = ZeroFormatterSerializer.Serialize(v3Array);
            //var serializer3 = this.msgPackContext.GetSerializer<Vector3>();
            //msgpackv3Bytes = serializer3.PackSingleObject(v3);
            //var serializer4 = this.msgPackContext.GetSerializer<Vector3[]>();
            //msgpackv3ArrayBytes = serializer4.PackSingleObject(v3Array);

            //jsonv3Bytes = Encoding.UTF8.GetBytes(JsonUtility.ToJson(v3));
            //jsonv3ArrayBytes = Encoding.UTF8.GetBytes(JsonUtility.ToJson(v3Array));
        }