public void SetConfigItem(string configKey, string configValue) { SystemConfigItem cfgItem = new SystemConfigItem() { ConfigKey = configKey, ConfigValue = configValue }; // Save or Update setting item SetConfigItem(cfgItem); }
// Methods .................................................... public string GetConfigItemValue(string configKey) { string itemValue = String.Empty; SystemConfigItem cfgItem = ConfigItems.FirstOrDefault(s => s.ConfigKey == configKey); if (cfgItem != null) { itemValue = cfgItem.ConfigValue; } return(itemValue); }
private void SetConfigItem(SystemConfigItem configItem) { // determine if the config item already exists SystemConfigItem cfgItem = ConfigItems.FirstOrDefault(s => s.ConfigKey == configItem.ConfigKey); // Create or update if (cfgItem == null) { cfgItem = new SystemConfigItem() { ConfigKey = configItem.ConfigKey, ConfigValue = configItem.ConfigValue }; // Add element to the list ConfigItems.Add(cfgItem); } else { // Update exiting element in list cfgItem.ConfigValue = configItem.ConfigValue; } }