Esempio n. 1
0
        public void WorkTests()
        {
            var binSer  = new BinarySerializer <Plane <ReactiveEngine> >();
            var xmlSer  = new XmlCustomSerializer <Plane <ReactiveEngine> >();
            var jsonSer = new JsonSerializer <Plane <ReactiveEngine> >();

            var aer = new Aeroport <Plane <ReactiveEngine> >("Кольцово");

            for (int i = 0; i < 10; ++i)
            {
                aer.Add(new Plane <ReactiveEngine>(100, 20000, "SuperJet", new ReactiveEngine("DoublePower")));
            }
            var aerCopy = aer;

            binSer.Serialize(aer, "aerBinary.dat");
            aer = binSer.Deserialize("aerBinary.dat");

            xmlSer.Serialize(aer, "aerXML.xml");
            aer = xmlSer.Deserialize("aerXML.xml");


            jsonSer.Serialize(aer, "aerjson.json");
            aer = jsonSer.Deserialize("aerjson.json");
            for (int i = 0; i < aer.Count; ++i)
            {
                Assert.AreEqual(aer.Aviation[i].Model, aerCopy.Aviation[i].Model);
                Assert.AreEqual(aer.Aviation[i].Capacity, aerCopy.Aviation[i].Capacity);
            }
        }
Esempio n. 2
0
        static void Main()
        {
            threads = new List <Thread>();
            tracer  = new Tracer();

            MultipleThreadMethod();

            var tracerResult = tracer.GetTraceResult();

            var tracerResultList = new List <ThreadResult>();

            tracerResultList.AddRange(tracerResult.ThreadResults.Values);

            var jsonSerializer     = new JsonCustomSerializer();
            var jsonSerializedText = jsonSerializer.Serialize(tracerResultList);

            var xmlSerializer     = new XmlCustomSerializer();
            var xmlSerializedText = xmlSerializer.Serialize(tracerResultList);

            var fileOutputResult    = new FileOutput();
            var consoleOutputResult = new ConsoleOutput();

            fileOutputResult.OutputData(jsonSerializedText, ".json");
            fileOutputResult.OutputData(xmlSerializedText, ".xml");

            consoleOutputResult.OutputData(jsonSerializedText);
            consoleOutputResult.OutputData(xmlSerializedText);

            Console.ReadLine();
        }