Exemple #1
0
        public static void NonDefaultConstructor()
        {
            var o = new nondefaultctor(10);
            //fastBinaryJSON.BJSON.Parameters.ParametricConstructorOverride = true;
            var s = fastBinaryJSON.BJSON.ToBJSON(o);

            Console.WriteLine(s);
            var obj = fastBinaryJSON.BJSON.ToObject <nondefaultctor>(s, new BJSONParameters {
                ParametricConstructorOverride = true
            });

            Assert.AreEqual(10, obj.age);
            List <nondefaultctor> l = new List <nondefaultctor> {
                o, o, o
            };

            s = fastBinaryJSON.BJSON.ToBJSON(l);
            var obj2 = fastBinaryJSON.BJSON.ToObject <List <nondefaultctor> >(s, new BJSONParameters {
                ParametricConstructorOverride = true
            });

            Assert.AreEqual(3, obj2.Count);
            Assert.AreEqual(10, obj2[1].age);
            //fastBinaryJSON.BJSON.Parameters.ParametricConstructorOverride = false;
        }
Exemple #2
0
        public void NonDefaultConstructor()
        {
            var o = new nondefaultctor(10);
            var s = JSON.ToJSON(o);

            Console.WriteLine(s);
            var obj = JSON.ToObject <nondefaultctor> (s, new JSONParameters {
                ParametricConstructorOverride = true, UsingGlobalTypes = true
            });

            Assert.AreEqual(10, obj.age);
            Console.WriteLine("list of objects");
            List <nondefaultctor> l = new List <nondefaultctor> {
                o, o, o
            };

            s = JSON.ToJSON(l);
            Console.WriteLine(s);
            var obj2 = JSON.ToObject <List <nondefaultctor> > (s, new JSONParameters {
                ParametricConstructorOverride = true, UsingGlobalTypes = true
            });

            Assert.AreEqual(3, obj2.Count);
            Assert.AreEqual(10, obj2[1].age);
        }
Exemple #3
0
        public void NonDefaultConstructor()
        {
            var o = new nondefaultctor(10);
            var s = Json.ToJson(o);

            Console.WriteLine(s);
            var obj = Json.ToObject <nondefaultctor> (s, new SerializationManager {
                ParametricConstructorOverride = true
            });

            Assert.AreEqual(10, obj.age);
            Console.WriteLine("list of objects");
            var l = new List <nondefaultctor> {
                o, o, o
            };

            s = Json.ToJson(l);
            Console.WriteLine(s);
            var obj2 = Json.ToObject <List <nondefaultctor> > (s, new SerializationManager {
                ParametricConstructorOverride = true
            });

            Assert.AreEqual(3, obj2.Count);
            Assert.AreEqual(10, obj2[1].age);
        }
Exemple #4
0
 public static void NonDefaultConstructor()
 {
     var o = new nondefaultctor(10);
     //fastBinaryJSON.BJSON.Parameters.ParametricConstructorOverride = true;
     var s = fastBinaryJSON.BJSON.ToBJSON(o);
     Console.WriteLine(s);
     var obj = fastBinaryJSON.BJSON.ToObject<nondefaultctor>(s, new BJSONParameters { ParametricConstructorOverride = true });
     Assert.AreEqual(10, obj.age);
     List<nondefaultctor> l = new List<nondefaultctor> { o, o, o };
     s = fastBinaryJSON.BJSON.ToBJSON(l);
     var obj2 = fastBinaryJSON.BJSON.ToObject<List<nondefaultctor>>(s, new BJSONParameters { ParametricConstructorOverride = true });
     Assert.AreEqual(3, obj2.Count);
     Assert.AreEqual(10, obj2[1].age);
     //fastBinaryJSON.BJSON.Parameters.ParametricConstructorOverride = false;
 }