Beispiel #1
0
        // Test Method
        public static void Test()
        {
            Console.WriteLine("***** Fun with Object Serialization using XmlFormatter *****\n");
            // Make a JamesBondCar and set state.
            JamesBondCar jbc = JamesBondCar.CreateDefaultCar();


            // Now save the car to a specific file in a binary format.
            SaveAsXmlFormat(jbc, "CarDataXml.dat");

            LoadFromXmlFile("CarDataXml.dat");
        }
Beispiel #2
0
        // Test Method
        public static void Test()
        {
            List <JamesBondCar> cars = new List <JamesBondCar>()
            {
                JamesBondCar.CreateDefaultCar(true, true, false),
                JamesBondCar.CreateDefaultCar(true, false, false),
                JamesBondCar.CreateDefaultCar(false, true, false),
                JamesBondCar.CreateDefaultCar(false, true, true)
            };

            Formatters.SerializeWithBinaryFormatter(cars, "CarStock.dat");

            Formatters.SerializeWithXmlSerializer <List <JamesBondCar> >(cars, "CarStockXml.dat");


            Console.WriteLine(string.Join($"{Environment.NewLine}", Formatters.LoadFromBinaryFile <List <JamesBondCar> >("CarStock.dat")));

            Console.WriteLine(string.Join($"{Environment.NewLine}", Formatters.LoadFromXmlFile <List <JamesBondCar> >("CarStockXml.dat")));
        }