Exemplo n.º 1
0
        static void Main(string[] args)
        {
            StaticContainerClass.XmlContainer toBeDeserialized = new StaticContainerClass.XmlContainer();

            toBeDeserialized.Entries = new List<StaticContainerClass.XmlContainerEntry>();
            toBeDeserialized.Entries.Add(new StaticContainerClass.XmlContainerEntry() { Id = Guid.NewGuid()});


            try
            {
                using (XmlTextWriter writer = new XmlTextWriter("test.xml", Encoding.UTF8))
                {
                    var serializer = new XmlSerializer(typeof(StaticContainerClass.XmlContainer));
                    serializer.Serialize(writer, toBeDeserialized);
                }
            }
            catch (Exception exc)
            {
                Console.WriteLine(exc);
            }
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            StaticContainerClass.XmlContainer toBeDeserialized = new StaticContainerClass.XmlContainer();

            toBeDeserialized.Entries = new List <StaticContainerClass.XmlContainerEntry>();
            toBeDeserialized.Entries.Add(new StaticContainerClass.XmlContainerEntry()
            {
                Id = Guid.NewGuid()
            });


            try
            {
                using (XmlTextWriter writer = new XmlTextWriter("test.xml", Encoding.UTF8))
                {
                    var serializer = new XmlSerializer(typeof(StaticContainerClass.XmlContainer));
                    serializer.Serialize(writer, toBeDeserialized);
                }
            }
            catch (Exception exc)
            {
                Console.WriteLine(exc);
            }
        }