예제 #1
0
        private JNSimpleObjectModel GetBaseModel()
        {
            var m = new JNSimpleObjectModel();
            m.IntValue = _rnd.Next();
            m.FloatValue = (float)_rnd.NextDouble();
            m.StringValue = Guid.NewGuid().ToString();
            m.IntList = new List<int> { _rnd.Next(), _rnd.Next(), _rnd.Next() };

            m.ObjectType = JNObjectType.BaseClass;

            return m;
        }
        private JNSimpleObjectModel GetBaseModel()
        {
            var m = new JNSimpleObjectModel();

            m.IntValue    = _rnd.Next();
            m.FloatValue  = (float)_rnd.NextDouble();
            m.StringValue = Guid.NewGuid().ToString();
            m.IntList     = new List <int> {
                _rnd.Next(), _rnd.Next(), _rnd.Next()
            };

            m.ObjectType = JNObjectType.BaseClass;

            return(m);
        }
예제 #3
0
        private JNSimpleObjectModel GetBaseModel()
        {
            JNSimpleObjectModel jNSimpleObjectModel = new JNSimpleObjectModel();

            jNSimpleObjectModel.IntValue    = this._rnd.Next();
            jNSimpleObjectModel.FloatValue  = (float)this._rnd.NextDouble();
            jNSimpleObjectModel.StringValue = Guid.NewGuid().ToString();
            JNSimpleObjectModel arg_77_0 = jNSimpleObjectModel;
            List <int>          list     = new List <int>();

            list.Add(this._rnd.Next());
            list.Add(this._rnd.Next());
            list.Add(this._rnd.Next());
            arg_77_0.IntList = list;
            jNSimpleObjectModel.ObjectType = JNObjectType.BaseClass;
            return(jNSimpleObjectModel);
        }
        public void Sample()
        {
            JNSimpleObjectModel jNSimpleObjectModel = new JNSimpleObjectModel();

            jNSimpleObjectModel.IntValue    = 5;
            jNSimpleObjectModel.FloatValue  = 4.98f;
            jNSimpleObjectModel.StringValue = "Simple Object";
            JNSimpleObjectModel arg_54_0 = jNSimpleObjectModel;
            List <int>          list     = new List <int>();

            list.Add(4);
            list.Add(7);
            list.Add(25);
            list.Add(34);
            arg_54_0.IntList = list;
            jNSimpleObjectModel.ObjectType = JNObjectType.BaseClass;
            JNSimpleObjectModel value = jNSimpleObjectModel;

            byte[] array = new byte[0];
            using (MemoryStream memoryStream = new MemoryStream())
            {
                using (BsonWriter bsonWriter = new BsonWriter(memoryStream))
                {
                    JsonSerializer jsonSerializer = new JsonSerializer();
                    jsonSerializer.Serialize(bsonWriter, value);
                }
                array = memoryStream.ToArray();
                string text = Convert.ToBase64String(array);
                Debug.Log(text);
            }
            JNSimpleObjectModel jNSimpleObjectModel2;

            using (MemoryStream memoryStream2 = new MemoryStream(array))
            {
                using (BsonReader bsonReader = new BsonReader(memoryStream2))
                {
                    JsonSerializer jsonSerializer2 = new JsonSerializer();
                    jNSimpleObjectModel2 = jsonSerializer2.Deserialize <JNSimpleObjectModel>(bsonReader);
                }
            }
            if (jNSimpleObjectModel2 != null)
            {
                Debug.Log(jNSimpleObjectModel2.StringValue);
            }
        }
예제 #5
0
        public void Sample()
        {
            JNSimpleObjectModel value = new JNSimpleObjectModel
            {
                IntValue    = 5,
                FloatValue  = 4.98f,
                StringValue = "Simple Object",
                IntList     = new List <int>
                {
                    4,
                    7,
                    25,
                    34
                },
                ObjectType = JNObjectType.BaseClass
            };

            byte[] array = new byte[0];
            using (MemoryStream memoryStream = new MemoryStream())
            {
                using (BsonWriter bsonWriter = new BsonWriter(memoryStream))
                {
                    JsonSerializer jsonSerializer = new JsonSerializer();
                    jsonSerializer.Serialize(bsonWriter, value);
                }
                array = memoryStream.ToArray();
                string text = Convert.ToBase64String(array);
                Debug.Log(text);
            }
            JNSimpleObjectModel jnsimpleObjectModel;

            using (MemoryStream memoryStream2 = new MemoryStream(array))
            {
                using (BsonReader bsonReader = new BsonReader(memoryStream2))
                {
                    JsonSerializer jsonSerializer2 = new JsonSerializer();
                    jnsimpleObjectModel = jsonSerializer2.Deserialize <JNSimpleObjectModel>(bsonReader);
                }
            }
            if (jnsimpleObjectModel != null)
            {
                Debug.Log(jnsimpleObjectModel.StringValue);
            }
        }
예제 #6
0
        public void Sample()
        {
            //Create an object to serialize
            var original = new JNSimpleObjectModel
                {
                    IntValue = 5,
                    FloatValue = 4.98f,
                    StringValue = "Simple Object",
                    IntList = new List<int> { 4, 7, 25, 34 },
                    ObjectType = JNObjectType.BaseClass
                };

            //This string is the JSON representation of the object
            string serialized = JsonConvert.SerializeObject(original);

            //Now we can deserialize this string back into an object
            var newobject = JsonConvert.DeserializeObject<JNSimpleObjectModel>(serialized);

            Debug.Log(newobject.IntList.Count);
        }
        public void Sample()
        {
            JNSimpleObjectModel jNSimpleObjectModel = new JNSimpleObjectModel()
            {
                IntValue    = 5,
                FloatValue  = 4.98f,
                StringValue = "Simple Object",
                IntList     = new List <int>()
                {
                    4,
                    7,
                    25,
                    34
                },
                ObjectType = JNObjectType.BaseClass
            };
            JNSimpleObjectModel jNSimpleObjectModel1 = JsonConvert.DeserializeObject <JNSimpleObjectModel>(JsonConvert.SerializeObject(jNSimpleObjectModel));

            Debug.Log(jNSimpleObjectModel1.IntList.Count);
        }
예제 #8
0
        public void Sample()
        {
            JNSimpleObjectModel jNSimpleObjectModel;
            JNSimpleObjectModel jNSimpleObjectModel1 = new JNSimpleObjectModel()
            {
                IntValue    = 5,
                FloatValue  = 4.98f,
                StringValue = "Simple Object",
                IntList     = new List <int>()
                {
                    4,
                    7,
                    25,
                    34
                },
                ObjectType = JNObjectType.BaseClass
            };
            JNSimpleObjectModel jNSimpleObjectModel2 = jNSimpleObjectModel1;

            byte[] array = new byte[0];
            using (MemoryStream memoryStream = new MemoryStream())
            {
                using (BsonWriter bsonWriter = new BsonWriter(memoryStream))
                {
                    (new JsonSerializer()).Serialize(bsonWriter, jNSimpleObjectModel2);
                }
                array = memoryStream.ToArray();
                Debug.Log(Convert.ToBase64String(array));
            }
            using (MemoryStream memoryStream1 = new MemoryStream(array))
            {
                using (BsonReader bsonReader = new BsonReader(memoryStream1))
                {
                    jNSimpleObjectModel = (new JsonSerializer()).Deserialize <JNSimpleObjectModel>(bsonReader);
                }
            }
            if (jNSimpleObjectModel != null)
            {
                Debug.Log(jNSimpleObjectModel.StringValue);
            }
        }
        public void Sample()
        {
            JNSimpleObjectModel value = new JNSimpleObjectModel
            {
                IntValue    = 5,
                FloatValue  = 4.98f,
                StringValue = "Simple Object",
                IntList     = new List <int>
                {
                    4,
                    7,
                    25,
                    34
                },
                ObjectType = JNObjectType.BaseClass
            };
            string value2 = JsonConvert.SerializeObject(value);
            JNSimpleObjectModel jnsimpleObjectModel = JsonConvert.DeserializeObject <JNSimpleObjectModel>(value2);

            Debug.Log(jnsimpleObjectModel.IntList.Count);
        }
        public void Sample()
        {
            //Create an object to serialize
            var original = new JNSimpleObjectModel
            {
                IntValue    = 5,
                FloatValue  = 4.98f,
                StringValue = "Simple Object",
                IntList     = new List <int> {
                    4, 7, 25, 34
                },
                ObjectType = JNObjectType.BaseClass
            };

            //This string is the JSON representation of the object
            string serialized = JsonConvert.SerializeObject(original);

            //Now we can deserialize this string back into an object
            var newobject = JsonConvert.DeserializeObject <JNSimpleObjectModel>(serialized);

            Debug.Log(newobject.IntList.Count);
        }
        public void Sample()
        {
            JNSimpleObjectModel jNSimpleObjectModel = new JNSimpleObjectModel();

            jNSimpleObjectModel.IntValue    = 5;
            jNSimpleObjectModel.FloatValue  = 4.98f;
            jNSimpleObjectModel.StringValue = "Simple Object";
            JNSimpleObjectModel arg_4F_0 = jNSimpleObjectModel;
            List <int>          list     = new List <int>();

            list.Add(4);
            list.Add(7);
            list.Add(25);
            list.Add(34);
            arg_4F_0.IntList = list;
            jNSimpleObjectModel.ObjectType = JNObjectType.BaseClass;
            JNSimpleObjectModel value = jNSimpleObjectModel;
            string value2             = JsonConvert.SerializeObject(value);
            JNSimpleObjectModel jNSimpleObjectModel2 = JsonConvert.DeserializeObject <JNSimpleObjectModel>(value2);

            Debug.Log(jNSimpleObjectModel2.IntList.get_Count());
        }
예제 #12
0
        public void Sample()
        {
            List <JNSimpleObjectModel> list = new List <JNSimpleObjectModel>();

            for (int i = 0; i < 3; i++)
            {
                list.Add(this.GetBaseModel());
            }
            for (int j = 0; j < 2; j++)
            {
                list.Add(this.GetSubClassModel());
            }
            for (int k = 0; k < 3; k++)
            {
                list.Add(this.GetBaseModel());
            }
            JsonSerializerSettings settings = new JsonSerializerSettings
            {
                TypeNameHandling = TypeNameHandling.All
            };
            string value = JsonConvert.SerializeObject(list, Formatting.None, settings);
            List <JNSimpleObjectModel> list2 = JsonConvert.DeserializeObject <List <JNSimpleObjectModel> >(value, settings);

            for (int l = 0; l < list2.get_Count(); l++)
            {
                JNSimpleObjectModel jNSimpleObjectModel = list2.get_Item(l);
                if (jNSimpleObjectModel.ObjectType == JNObjectType.SubClass)
                {
                    Debug.Log((jNSimpleObjectModel as JNSubClassModel).SubClassStringValue);
                }
                else
                {
                    Debug.Log(jNSimpleObjectModel.StringValue);
                }
            }
        }
예제 #13
0
        public void Sample()
        {
            //Create an object to serialize
            var original = new JNSimpleObjectModel
            {
                IntValue    = 5,
                FloatValue  = 4.98f,
                StringValue = "Simple Object",
                IntList     = new List <int> {
                    4, 7, 25, 34
                },
                ObjectType = JNObjectType.BaseClass
            };

            //Placeholder to hold the serialized data so we can deserialize it later
            byte[] serializedData = new byte[] {};

            //Create a memory stream to hold the serialized bytes
            using (var stream = new MemoryStream())
            {
                using (BsonWriter writer = new BsonWriter(stream))
                {
                    JsonSerializer serializer = new JsonSerializer();
                    serializer.Serialize(writer, original);
                }

                //Read the stream to a byte array.  We could
                //just as easily output it to a file
                serializedData = stream.ToArray();

                //You could write the raw bytes to a file, here we're converting
                //them to a base-64 string and writing out to the debug log
                var serialized = Convert.ToBase64String(serializedData);
                Debug.Log(serialized);
            }

            //Placeholder for our deserialized object so it's available outside
            //of the using block

            JNSimpleObjectModel newObject;

            //Now that we have a byte array of our serialized data, let's Deserialize it.
            using (var stream = new MemoryStream(serializedData))
            {
                using (BsonReader reader = new BsonReader(stream))
                {
                    //If you're deserializing a collection, the following option
                    //must be set to instruct the reader that the root object
                    //is actually an array / collection type.
                    //
                    //reader.ReadRootValueAsArray = true;

                    JsonSerializer serializer = new JsonSerializer();
                    newObject = serializer.Deserialize <JNSimpleObjectModel>(reader);
                }
            }

            if (newObject != null)
            {
                Debug.Log(newObject.StringValue);
            }



            //Debug.Log(newobject.IntList.Count);
        }
예제 #14
0
        public void Sample()
        {
            //Create an object to serialize
            var original = new JNSimpleObjectModel
            {
                IntValue = 5,
                FloatValue = 4.98f,
                StringValue = "Simple Object",
                IntList = new List<int> { 4, 7, 25, 34 },
                ObjectType = JNObjectType.BaseClass
            };

            //Placeholder to hold the serialized data so we can deserialize it later
            byte[] serializedData = new byte[]{}; 

            //Create a memory stream to hold the serialized bytes
            using(var stream  = new MemoryStream())
            {
                using (BsonWriter writer = new BsonWriter(stream))
                {
                    JsonSerializer serializer = new JsonSerializer();
                    serializer.Serialize(writer, original);
                }

                //Read the stream to a byte array.  We could 
                //just as easily output it to a file
                serializedData = stream.ToArray();

                //You could write the raw bytes to a file, here we're converting 
                //them to a base-64 string and writing out to the debug log
                var serialized = Convert.ToBase64String(serializedData);
                Debug.Log(serialized);
            }

            //Placeholder for our deserialized object so it's available outside 
            //of the using block

            JNSimpleObjectModel newObject;

            //Now that we have a byte array of our serialized data, let's Deserialize it.
            using (var stream = new MemoryStream(serializedData))
            {
                using (BsonReader reader = new BsonReader(stream))
                {
                    //If you're deserializing a collection, the following option 
                    //must be set to instruct the reader that the root object 
                    //is actually an array / collection type.
                    //
                    //reader.ReadRootValueAsArray = true;

                    JsonSerializer serializer = new JsonSerializer();
                    newObject = serializer.Deserialize<JNSimpleObjectModel>(reader);
                }
            }

            if (newObject != null)
            {
                Debug.Log(newObject.StringValue);
            }
            


            

            


            //Debug.Log(newobject.IntList.Count);
        }