Beispiel #1
0
        private void DeserializeObject()
        {
            objectDeserializer = new Serializators();

            LoadAssemblies("PlanePlugin.dll");
            LoadAssemblies("HelicopterPlugin.dll");

            string      path = @"serial.bin";
            ListOfTypes typeList;

            JsonSerializer serializer = new JsonSerializer();
            MemoryStream   ms         = new MemoryStream();
            string         data       = string.Empty;

            data = System.IO.File.ReadAllText(path);
            string[]     dataList = data.Split(' ');
            byte[]       bdata    = Convert.FromBase64String(dataList[dataList.Length - 1]);
            MemoryStream ms1      = new MemoryStream(bdata);

            using (BsonReader reader = new BsonReader(ms1))
            {
                JsonSerializer deserializer = new JsonSerializer();
                typeList = deserializer.Deserialize <ListOfTypes>(reader);
            }

            for (int i = 0; i < typeList.Content.Count; i++)
            {
                transports.Add(objectDeserializer.Deserialize(typeList.Content[i], dataList[i]));
            }
        }
Beispiel #2
0
        private void DeserializeObject()
        {
            string        path = @"D:\serial.bin";
            Wrapper       typeList;
            Serializators objectDeserializer = new Serializators();

            JsonSerializer serializer = new JsonSerializer();
            MemoryStream   ms         = new MemoryStream();
            string         data       = string.Empty;

            data = System.IO.File.ReadAllText(path);
            string[]     dataList = data.Split(' ');
            byte[]       bdata    = Convert.FromBase64String(dataList[dataList.Length - 1]);
            MemoryStream ms1      = new MemoryStream(bdata);

            using (BsonReader reader = new BsonReader(ms1))
            {
                JsonSerializer deserializer = new JsonSerializer();
                typeList = deserializer.Deserialize <Wrapper>(reader);
            }

            for (int i = 0; i < typeList.Content.Count; i++)
            {
                transports.Add(objectDeserializer.Serialize(typeList.Content[i], dataList[i]));
            }
        }