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();
        }
Beispiel #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();
        }
Beispiel #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();
        }
        } = Encoding.UTF8;                                               // set by FileMessageStore

        /// <summary>
        /// Deserializes the <see cref="MailMergeMessage"/> and returns a new message object.
        /// </summary>
        /// <returns>Returns the deserialized object from the <see cref="MessageFile"/>.</returns>
        public override MailMergeMessage LoadMessage()
        {
            return(SerializationFactory.Deserialize <MailMergeMessage>(MessageFile.FullName, MessageEncoding));
        }
Beispiel #5
0
 /// <summary>
 /// Reads <see cref="Templates"/> from an XML file.
 /// </summary>
 /// <param name="filename"></param>
 /// <param name="encoding"></param>
 public static Templates Deserialize(string filename, System.Text.Encoding encoding)
 {
     return(SerializationFactory.Deserialize <Templates>(filename, encoding));
 }
Beispiel #6
0
 /// <summary>
 /// Reads <see cref="Templates"/> from an XML stream.
 /// </summary>
 /// <param name="stream"></param>
 /// <param name="encoding"></param>
 public static Templates Deserialize(Stream stream, System.Text.Encoding encoding)
 {
     return(SerializationFactory.Deserialize <Templates>(new StreamReader(stream, encoding), true));
 }
Beispiel #7
0
 /// <summary>
 /// Deserialize the parameter with XML markup to an instance of <see cref="Templates"/>.
 /// </summary>
 /// <param name="xml"></param>
 /// <returns>Returns an instance of <see cref="Templates"/>.</returns>
 public static Templates Deserialize(string xml)
 {
     return(SerializationFactory.Deserialize <Templates>(xml));
 }
Beispiel #8
0
 /// <summary>
 /// Read the MailMergeLib settings from an xml string.
 /// </summary>
 /// <returns>Returns the MailMergeLib settings as an xml string.</returns>
 public static Settings Deserialize(string xml)
 {
     return(SerializationFactory.Deserialize <Settings>(xml));
 }
Beispiel #9
0
 /// <summary>
 /// Reads MailMergeLib settings from a file.
 /// </summary>
 /// <param name="filename"></param>
 /// <param name="encoding"></param>
 public static Settings Deserialize(string filename, Encoding encoding)
 {
     return(SerializationFactory.Deserialize <Settings>(filename, encoding));
 }
Beispiel #10
0
 /// <summary>
 /// Reads MailMergeLib settings from a stream.
 /// </summary>
 /// <param name="stream"></param>
 /// <param name="encoding"></param>
 public static Settings Deserialize(Stream stream, Encoding encoding)
 {
     return(SerializationFactory.Deserialize <Settings>(new StreamReader(stream, encoding), true));
 }