/// <summary>
 /// Saves the settings in the db
 /// </summary>
 /// <param name="config"></param>
 public void SaveSetting(SettingConfigurationElement element)
 {
     string elementName = null;
     if (element is GeneralElement)
     {
         elementName = "general";
     }
     else if (element is UIElement)
     {
         elementName = "ui";
     }
     else if (element is SpamPreventionElement)
     {
         elementName = "spamPrevention";
     }
     else if (element is SearchElement)
     {
         elementName = "search";
     }
     else
     {
         throw new NotSupportedException("Element of type " + element.GetType().Name + " is not supported.");
     }
     element.ValidateFields();
     SaveElement(element, elementName);
 }
Esempio n. 2
0
        /// <summary>
        /// Saves current settings.
        /// </summary>
        /// <exception cref="ValidationException"></exception>
        public virtual void SaveSetting(SettingConfigurationElement element)
        {
            if (!UseSettings)
            {
                throw new ConfigurationErrorsException("Saving settings is not possible when is not enabled by configuration (useSettings)");
            }
            if (_settingsRepository == null)
            {
                throw new NullReferenceException("settings repository can not be null");
            }
            _settingsRepository.SaveSetting(element);

            if (element is GeneralElement)
            {
                General = (GeneralElement) element;
            }
            else if (element is UIElement)
            {
                UI = (UIElement)element;
            }
            else if (element is SpamPreventionElement)
            {
                SpamPrevention = (SpamPreventionElement)element;
            }
            else if (element is SearchElement)
            {
                Search = (SearchElement)element;
            }
            else
            {
                throw new NotSupportedException("Element of type " + element.GetType().Name + " is not supported.");
            }
        }