/// <summary> /// Add or update a value to the collection of key value sets /// </summary> /// <param name="key"></param> /// <param name="value"></param> public void Set(TKeyType key, TValueType value) { var keyValueSet = new KeyValueSet <TKeyType, TValueType>(key, value); if (IsKeyPresent(key)) { Update(key, value); return; } KeyValueSets.Add(keyValueSet); }
public void Add(KeyValueSet set) { if (set == null) { throw new InvalidOperationException("Cannot add null"); } if (string.IsNullOrEmpty(set.KeyStr) && set.KeyInt == 0) { throw new InvalidOperationException("Invalid key"); } if (!string.IsNullOrEmpty(set.KeyStr) && _list.Any(l => l.KeyStr.Equals(set.KeyStr)) || set.KeyInt != 0 && _list.Any(l => l.KeyInt == set.KeyInt)) { throw new InvalidOperationException("Either of keys exists"); } _list.Add(set); }
public void Remove(KeyValueSet item) { _list.Remove(item); }