Пример #1
0
        /// <summary>
        /// Remove the given list from the dictionary.
        /// Raises the OnRemoveList event
        /// </summary>
        /// <param name="keys"></param>
        public void RemoveList(List <string> keys)
        {
            try
            {
                foreach (var key in keys)
                {
                    Keys.TryRemove(key, out _);
                }

                OnRemoveList?.Invoke(this, new DictionaryEventArgs(keys, true));
            }
            catch (Exception e)
            {
                if (e is ChainingException exception)
                {
                    exception.AddErrorToChain("While trying to remove key from count dictionary");
                }
                else
                {
                    exception = new ChainingException(e.Message);
                    exception.AddErrorToChain("While trying to remove key from count dictionary");
                }
                throw exception;
            }
        }
Пример #2
0
 /// <summary>
 /// Clears the content of the dictionary.
 /// Raises the OnRemoveList envent.
 /// </summary>
 public void Clear()
 {
     try
     {
         List <string>?keys = Keys.Keys as List <string>;
         Keys.Clear();
         if (keys != null)
         {
             OnRemoveList?.Invoke(this, new DictionaryEventArgs(keys, true));
         }
     }
     catch (Exception e)
     {
         if (e is ChainingException exception)
         {
             exception.AddErrorToChain("While trying to clear the count dictionary");
         }
         else
         {
             exception = new ChainingException(e.Message);
             exception.AddErrorToChain("While trying to clear the count dictionary");
         }
         throw exception;
     }
 }