Exemplo n.º 1
0
        private Dictionary <string, KeyValuePair <int, string> > GetSettingsDictionary()
        {
            //format: <name, <id, value>>
            var dictionary = new Dictionary <string, KeyValuePair <int, string> >();

            foreach (var s in AllSettings.Where(setting => setting.Site != null && setting.Site.Id == _site.Id))
            {
                var resourceName = s.Name.ToLowerInvariant();
                if (!dictionary.ContainsKey(resourceName))
                {
                    dictionary.Add(resourceName, new KeyValuePair <int, string>(s.Id, s.Value));
                }
            }
            if (!dictionary.Keys.Any())
            {
                try
                {
                    if (!_retryingDictionary)
                    {
                        CurrentRequestData.ErrorSignal.Raise(
                            new Exception("settings dictionary empty for " + _site.DisplayName));
                    }
                }
                catch
                {
                } if (!_retryingDictionary)
                {
                    _retryingDictionary = true;
                    ResetSettingCache();
                    dictionary = GetSettingsDictionary();
                }
            }
            return(dictionary);
        }
Exemplo n.º 2
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();
 }
Exemplo n.º 3
0
        public void Remove(string subfolderName)
        {
            Settings stngs = AllSettings
                             .Where(settings => settings.SubfolderName == subfolderName)
                             .FirstOrDefault();

            if (stngs != null)
            {
                AllSettings.Remove(stngs);
            }
            SaveInFile();
        }
Exemplo n.º 4
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;
            }
        }