Example #1
0
 public void Add(string subfolderName, string bindedKey, bool?isMoveFileMode)
 {
     if (AllSettings.Where(settings => settings.SubfolderName == subfolderName ||
                           settings.Key == bindedKey).
         FirstOrDefault() == null)
     {
         AllSettings.Add(new Settings(subfolderName, bindedKey, isMoveFileMode));
     }
     SaveInFile();
 }
Example #2
0
 public void RefreshSettings(List <string> subfolderNames, List <string> bindedKeys, List <bool?> isMoveFileModes)
 {
     AllSettings.Clear();
     for (int i = 0; i < subfolderNames.Count; i++)
     {
         AllSettings.Add(new Settings(
                             subfolderNames[i], bindedKeys[i], isMoveFileModes[i]));
     }
     SaveInFile();
 }
Example #3
0
        // Keeps local settings synchronized with updates during a single request
        // Does not update database
        public void AddOrUpdateLocalSetting(StoreSetting s, bool preserveNotLocalizedValue = false)
        {
            // Search local settings storage for setting
            var found = AllSettings.Where(y => y.SettingName == s.SettingName).FirstOrDefault();

            if (found == null)
            {
                AllSettings.Add(s);
            }
            else
            {
                s.Id = found.Id; // Set Id so we'll get a database update instead of insert
                if (preserveNotLocalizedValue)
                {
                    s.SettingValue = found.SettingValue;
                }
                AllSettings[AllSettings.IndexOf(found)] = s;
            }
        }
Example #4
0
        /// <summary>
        /// Set setting value
        /// </summary>
        /// <typeparam name="T">Type</typeparam>
        /// <param name="key">Key</param>
        /// <param name="value">Value</param>
        public virtual void SetSetting <T>(string key, T value)
        {
            lock (SetSettingLockObject)
            {
                using (new SiteFilterDisabler(_session))
                {
                    if (key == null)
                    {
                        throw new ArgumentNullException("key");
                    }
                    key = key.Trim().ToLowerInvariant();

                    Setting setting =
                        _session.QueryOver <Setting>().Where(s => s.Site == _site && s.Name == key).SingleOrDefault();
                    string valueStr = typeof(T).GetCustomTypeConverter().ConvertToInvariantString(value);
                    if (setting != null)
                    {
                        //update
                        setting.Value = valueStr;
                        setting.Site  = _site;
                    }
                    else
                    {
                        //insert
                        setting = new Setting
                        {
                            Name  = key,
                            Value = valueStr,
                            Site  = _site
                        };
                        AllSettings.Add(setting);
                    }
                    _session.Transact(session => session.SaveOrUpdate(setting));
                }
            }
        }