コード例 #1
0
        static void Main(string[] args)
        {
            var    helpers       = new Streaming();
            var    serialization = new SerializationFactory().GetSerializationClass(SerializationType.XmlSerialization);
            string filename      = AppDomain.CurrentDomain.BaseDirectory + "XmlSerializableData.xml";

            var shop = new Shop {
                name = "my shop", rating = 2
            };
            Stream strShop = serialization.Serialize(shop);

            strShop.Position = 0;

            helpers.SaveToDisk(strShop, filename);

            Stream savedShop = helpers.LoadFromDisk(filename);
            Shop   desPerson = serialization.Deserialize <Shop>(savedShop);

            Console.ReadLine();
        }
コード例 #2
0
        static void Main(string[] args)
        {
            var    helpers        = new Streaming();
            var    bSerialization = new BSerialization();
            string filename       = AppDomain.CurrentDomain.BaseDirectory + "binaryFile";
            var    shop           = new Shop {
                name = "serialized name", rating = 10
            };

            Stream strShop = bSerialization.Serialize(shop);

            strShop.Position = 0;

            helpers.SaveToDisk(strShop, filename);

            Stream savedShop = helpers.LoadFromDisk(filename);
            Shop   desShop   = bSerialization.Deserialize <Shop>(savedShop);

            Console.ReadLine();
        }
コード例 #3
0
        static void Main(string[] args)
        {
            var    helpers       = new Streaming();
            var    serialization = new SerializationFactory().GetSerializationClass(SerializationType.Binary);
            string filename      = AppDomain.CurrentDomain.BaseDirectory + "binaryFile";
            var    person        = new Person {
                address = new Address {
                    city = "my city", country = "my country"
                }, age = 34, name = "Sebastian", id = "11"
            };

            Stream strPerson = serialization.Serialize(person);

            strPerson.Position = 0;

            helpers.SaveToDisk(strPerson, filename);

            Stream savedPerson = helpers.LoadFromDisk(filename);
            Person desPerson   = serialization.Deserialize <Person>(savedPerson);

            Console.ReadLine();
        }
コード例 #4
0
        static void Main(string[] args)
        {
            var    helpers       = new Streaming();
            var    serialization = new SerializationFactory().GetSerializationClass(SerializationType.XmlSerialization);
            string filename      = AppDomain.CurrentDomain.BaseDirectory + "XmlSerializableData.xml";

            var person = new Person {
                Address = new Address {
                    City = "my city", Country = "my country"
                }, Age = 34, Name = "Sebastian", Id = "11", CreditCardPin = "1111", Nickname = "Genius"
            };

            Stream strPerson = serialization.Serialize(person);

            strPerson.Position = 0;

            helpers.SaveToDisk(strPerson, filename);

            Stream savedPerson = helpers.LoadFromDisk(filename);
            Person desPerson   = serialization.Deserialize <Person>(savedPerson);

            Console.ReadLine();
        }