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); }
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(); }
public void Remove(string subfolderName) { Settings stngs = AllSettings .Where(settings => settings.SubfolderName == subfolderName) .FirstOrDefault(); if (stngs != null) { AllSettings.Remove(stngs); } SaveInFile(); }
// 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; } }