static void ChangeSettings(SettingsKey Key, string Value) { XmlNode SettingsNode = Settings.DocumentElement.SelectSingleNode("SETTINGS"); foreach (XmlNode Setting in SettingsNode.ChildNodes) { if (Setting.Attributes["NAME"].Value != Key.ToString()) { continue; } Setting.Attributes["VALUE"].Value = Value; return; } XmlNode NewSetting = Settings.CreateElement("KEY"); XmlAttribute Attrib = Settings.CreateAttribute("NAME"); Attrib.Value = Key.ToString(); NewSetting.Attributes.Append(Attrib); Attrib = Settings.CreateAttribute("NAME"); Attrib.Value = Value; NewSetting.Attributes.Append(Attrib); SettingsNode.AppendChild(NewSetting); }
public T GetData <T>(SettingsKey key) { try { if (ApplicationData.Current.LocalSettings.Values.ContainsKey(key.ToString())) { return((T)ApplicationData.Current.LocalSettings.Values[key.ToString()]); } return(default(T)); } catch (Exception) { return(default(T)); } }
T Parse <T>(string value, SettingsKey key) { try { dynamic retValue = null; if (typeof(T) == typeof(int)) { retValue = Int32.Parse(value); } else if (typeof(T) == typeof(string)) { retValue = value; } else if (typeof(T) == typeof(bool)) { retValue = Boolean.Parse(value); } else if (typeof(T) == typeof(decimal)) { retValue = Decimal.Parse(value); } if (retValue != null) { return(retValue); } return((T)Activator.CreateInstance(typeof(T), typeof(T) == typeof(string) ? new Char[1] : null)); } catch (FormatException) { Log.Error(String.Format("Setting value {0} has invalid format.", key.ToString())); throw new Exception(String.Format("Setting value {0} has invalid format.", key.ToString())); } }
public static string GetConfigValue(SettingsKey Key) { string FileName = StartupPath + @"\Configs\ServiceConfig.xml"; string value = clsSysUtils.ReadSetting(FileName, Key.ToString()); // Logger.TranferDataLog("valueKey "+ Key.ToString() + " " + value); return(value); }
public string GetSettings(SettingsKey key) { using (var context = new InstantStoreDataContext()) { var keyString = key.ToString(); var setting = context.Settings.FirstOrDefault(x => x.Key == keyString); return(setting != null ? setting.Value : null); } }
static string GetSettingsAsString(SettingsKey Key) { XmlNodeList SettingsList = Settings.DocumentElement.SelectSingleNode("SETTINGS").ChildNodes; string returnValue = string.Empty; foreach (XmlNode Setting in SettingsList) { if (Setting.Attributes["NAME"].Value != Key.ToString()) continue; returnValue = Setting.Attributes["VALUE"].Value; break; } return returnValue; }
public static T ReadSetting <T>(SettingsKey key, T defaultValue) { var keyString = key.ToString(); var localSettings = ApplicationData.Current.LocalSettings; if (localSettings.Values.ContainsKey(keyString)) { return((T)localSettings.Values[keyString]); } if (null != defaultValue) { return(defaultValue); } return(default);
public void SetSettings(SettingsKey key, string value) { using (var context = new InstantStoreDataContext()) { var keyString = key.ToString(); var setting = context.Settings.FirstOrDefault(x => x.Key == keyString); if (setting != null) { setting.Value = value; } else { context.Settings.InsertOnSubmit(new Setting { Key = keyString, Value = value }); } context.SubmitChanges(); } }
public void SetSettingAsString(SettingsKey Key, string Data) { SetSettingAsString_FromString(Key.ToString(), Data); }
public string GetSettingsAsString(SettingsKey Key) { return(GetSettingsAsString_FromString(Key.ToString())); }
static void ChangeSettings(SettingsKey Key, string Value) { XmlNode SettingsNode = Settings.DocumentElement.SelectSingleNode("SETTINGS"); foreach (XmlNode Setting in SettingsNode.ChildNodes) { if (Setting.Attributes["NAME"].Value != Key.ToString()) continue; Setting.Attributes["VALUE"].Value = Value; return; } XmlNode NewSetting = Settings.CreateElement("KEY"); XmlAttribute Attrib = Settings.CreateAttribute("NAME"); Attrib.Value = Key.ToString(); NewSetting.Attributes.Append(Attrib); Attrib = Settings.CreateAttribute("NAME"); Attrib.Value = Value; NewSetting.Attributes.Append(Attrib); SettingsNode.AppendChild(NewSetting); }
public void Save(SettingsKey key, object value) { _settings.Values[key.ToString()] = value; }
public T Get <T>(SettingsKey key) where T : class { var result = _settings.Values[key.ToString()] as T; return(result); }
public void SetData(SettingsKey key, object value) { ApplicationData.Current.LocalSettings.Values[key.ToString()] = value; }
public tbl_SettingsValue GetValueByKey(SettingsKey key, int domainID) { string skey = key.ToString(); return(this.DbSet.FirstOrDefault(s => s.SV_DomainID == domainID && s.tbl_Settings.SE_Variable.Equals(skey))); }
public tbl_Settings GetValueByKey(SettingsKey key) { string skey = key.ToString(); return(this.DbSet.FirstOrDefault(s => s.SE_Variable.Equals(skey))); }