SobekCM.Core.Aggregations.Complete_Item_Aggregation.Add_Setting C# (CSharp) Метод

Add_Setting() публичный Метод

Add a key/value pair setting to this aggregation
If a value already exists for the provided key, the value will be changed to the new value provided to this method.
public Add_Setting ( string Key, string Value ) : void
Key string Key for this setting
Value string Value for this setting
Результат void
        public void Add_Setting(string Key, string Value)
        {
            // Look for existing key that matches

            // Ensure the list is defined
            if (Settings == null) Settings = new List<StringKeyValuePair>();

            // Ensure the dictionary was built
            if (settingLookupDictionary == null) settingLookupDictionary = new Dictionary<string, StringKeyValuePair>(StringComparer.OrdinalIgnoreCase);
            if (settingLookupDictionary.Count != Settings.Count)
            {
                foreach (StringKeyValuePair setting in Settings)
                    settingLookupDictionary[setting.Key] = setting;
            }

            // Does this key already exist?
            if (settingLookupDictionary.ContainsKey(Key))
                settingLookupDictionary[Key].Value = Value;
            else
            {
                StringKeyValuePair newValue = new StringKeyValuePair(Key, Value);
                Settings.Add(newValue);
                settingLookupDictionary[Key] = newValue;
            }
        }