Exemplo n.º 1
0
        /// <summary>
        /// Loads this instance data from serialized file.
        /// </summary>
        /// <returns></returns>
        public static Preferences Load()
        {
            var dataFile = Path.Combine(Path.GetDirectoryName(CoreAssembly.GetAssemblyLocation().ToString()), "prefs.cbb");

            using (var stream = new FileStream(dataFile, FileMode.Open))
            {
                // Loads saved serialized data and return it as Preferences object.
                var deserializer = new XmlSerializer(typeof(Preferences));
                return((Preferences)deserializer.Deserialize(stream));
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Saves this instance of preferences in the .cbb file as xml structured data.
        /// </summary>
        public void Save()
        {
            // Store file in the location relative to the core executing assembly.
            var dataFile = Path.Combine(Path.GetDirectoryName(CoreAssembly.GetAssemblyLocation().ToString()), file);

            using (var stream = new FileStream(dataFile, FileMode.Create))
            {
                // Serialize state of the object in the file.
                var serializer = new XmlSerializer(typeof(Preferences));
                serializer.Serialize(stream, this);
            }
        }