예제 #1
0
파일: Program.cs 프로젝트: ledgarl/Samples
        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);
            }
        }
예제 #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);
            }
        }