예제 #1
0
        /// <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);
        }
예제 #2
0
 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);
 }
예제 #3
0
 public void Remove(KeyValueSet item)
 {
     _list.Remove(item);
 }