Ejemplo n.º 1
0
        /// <summary>
        /// Loads the settings service contents from the settings file.
        /// </summary>
        /// <remarks>
        /// If settings exist that were never saved, they'll be overwritten by this operation.
        /// </remarks>
        public void Load()
        {
            EnsureFileName();
            if (!File.Exists(fileName))
            {
                // Create the default settings file (from the one
                // embedded in the assembly's resource)
                Clear();
                var xdoc = XDocument.Parse(
                    CoreProperties.Resources.defaultSettings,
                    LoadOptions.PreserveWhitespace);
                FileHelper.CreateDirectoryIfNeeded(
                    Path.GetDirectoryName(fileName));
                xdoc.Save(fileName);
            }

            try
            {
                var xdoc = XDocument.Load(fileName);
                globalSettings = new GlobalSettings();
                globalSettings.Load(xdoc.Element("settings").Element("global"));
            }
            catch (Exception ex)
            {
                if (isRunningInsideLambda) throw;
                else onCorrupted(ex); // this tries to recover from the error.
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Clears the settings service contents.
 /// </summary>
 private void Clear()
 {
     //TODO: implement Clear
     globalSettings = new GlobalSettings();
     globalSettings.Clear();
 }