Ejemplo n.º 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();
        }
Ejemplo n.º 2
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();
        }
Ejemplo n.º 3
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();
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Write <see cref="Templates"/> with a StreamWriter.
 /// </summary>
 /// <param name="writer"></param>
 /// <param name="isStream">If true, the writer will not be closed and disposed, so that the underlying stream can be used on return.</param>
 private void Serialize(TextWriter writer, bool isStream)
 {
     SerializationFactory.Serialize(this, writer, isStream);
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Write <see cref="Templates"/> to a file.
 /// </summary>
 /// <param name="filename"></param>
 /// <param name="encoding"></param>
 public void Serialize(string filename, Encoding encoding)
 {
     SerializationFactory.Serialize(this, filename, encoding);
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Serialize <see cref="Templates"/> to XML.
 /// </summary>
 /// <returns>Returns a string with XML markup.</returns>
 public string Serialize()
 {
     return(SerializationFactory.Serialize <Templates>(this));
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Get MailMergeLib settings as an xml string.
 /// </summary>
 /// <returns>Returns the MailMergeLib settings as an xml string.</returns>
 public string Serialize()
 {
     return(SerializationFactory.Serialize(this));
 }