Exemplo n.º 1
0
        public static bool Serialise()
        {
            var    serializer = new DataContractSerializer(OM.GetType(), null, Int32.MaxValue, false, false, null, new SharedTypeResolver());
            string xmlString;

            using (var sw = new StringWriter())
            {
                using (var writer = new XmlTextWriter(sw))
                {
                    writer.Formatting = Formatting.Indented;
                    serializer.WriteObject(writer, OM);
                    writer.Flush();
                    xmlString = sw.ToString();
                }
            }


            var xd = new XmlDocument();

            xd.LoadXml(xmlString);

            string filename = SerialiseLocation + "\\XLOM_DataStore.xml";

            xd.Save(filename);

            return(true);
        }
Exemplo n.º 2
0
        public static bool Deserialise()
        {
            string filename = SerialiseLocation + "\\XLOM_DataStore.xml";

            var                 deserializer = new DataContractSerializer(OM.GetType(), null, Int32.MaxValue, false, false, null, new SharedTypeResolver());
            FileStream          fs           = new FileStream(filename, FileMode.Open);
            XmlDictionaryReader reader       = XmlDictionaryReader.CreateTextReader(fs, new XmlDictionaryReaderQuotas());

            OM = (Dictionary <OMKey, object>)deserializer.ReadObject(reader);
            reader.Close();
            fs.Close();

            return(true);
        }