Example #1
0
 /// <summary>
 /// The save.
 /// </summary>
 /// <param name="settings">
 /// The settings.
 /// </param>
 public static void Save(Settings settings)
 {
     ConfigHelper.DataContext.SettingsData.Save(settings);
 }
Example #2
0
        /// <summary>
        /// The get time zone info.
        /// </summary>
        /// <returns>
        /// The System.String.
        /// </returns>
        /// <exception cref="ApplicationException">
        /// Application exception
        /// </exception>
        private static string GetTimeZoneInfo()
        {
            Settings app = new Settings();
            XElement root = null;

            try
            {
                root = XElement.Load(Path);
            }
            catch (Exception ex)
            {
                Logger.Log(NO_FILE_ERROR, ex);
                throw new ApplicationException(NO_FILE_ERROR, ex);
            }

            try
            {
                return root.Element("Timezone").Value;
            }
            catch (Exception ex)
            {
                Logger.Log(XML_FORMAT_ERROR, ex);
                throw new ApplicationException(XML_FORMAT_ERROR, ex);
            }
        }
Example #3
0
        /// <summary>
        /// Loads Settings XML into Settings object
        /// Called by Application settings management
        /// Called by RSS Feed Generation component
        /// </summary>
        /// <returns>The Settings</returns>
        public Settings Load()
        {
            Settings app = new Settings();
            XElement root = null;

            try
            {
                var p = this._path;
                root = XElement.Load(p);
            }
            catch (Exception ex)
            {
                Logger.Log(NO_FILE_ERROR, ex);
                throw new ApplicationException(NO_FILE_ERROR, ex);
            }

            try
            {
                app.Name = root.Element("Name").Value;
                app.Url = root.Element("Url").Value;
                app.PostCount = int.Parse(root.Element("PostCount").Value);
                app.CommentModeration = bool.Parse(root.Element("CommentModeration").Value);
                app.Timezone = root.Element("Timezone").Value;
            }
            catch (Exception ex)
            {
                Logger.Log(XML_FORMAT_ERROR, ex);
                throw new ApplicationException(XML_FORMAT_ERROR, ex);
            }

            return app;
        }
Example #4
0
        /// <summary>
        /// Saves settings data into XML
        /// Called by Settings management
        /// </summary>
        /// <param name="app">
        /// The Settings
        /// </param>
        public void Save(Settings app)
        {
            XElement root = null;

            try
            {
                root = XElement.Load(this._path);
            }
            catch (Exception ex)
            {
                Logger.Log(NO_FILE_ERROR, ex);
                throw new ApplicationException(NO_FILE_ERROR, ex);
            }

            try
            {
                XElement settings = new XElement(
                    "Settings",
                    new XElement("Name", app.Name),
                    new XElement("Url", app.Url),
                    new XElement("PostCount", app.PostCount),
                    new XElement("Timezone", app.Timezone),
                    new XElement("CommentModeration", app.CommentModeration));

                root.ReplaceNodes(settings.Elements());

                root.Save(this._path);
            }
            catch (Exception ex)
            {
                Logger.Log(XML_FORMAT_ERROR, ex);
                throw new ApplicationException(XML_FORMAT_ERROR, ex);
            }
        }