Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class CollectionHandlerEventArgs : System.EventArgs
- {
- public string NameCollection { get; set; }
- public string ChangeCollection { get; set; }
- public Pair Pair { get; set; }
- public CollectionHandlerEventArgs(string collectionName, string changes, Pair pair)
- {
- NameCollection = collectionName;
- ChangeCollection = changes;
- Pair = pair;
- }
- public override string ToString()
- {
- return NameCollection + ", " + ChangeCollection + ", " + Pair;
- }
- }
- public class MyCollection : Dictionary<int, Pair>
- {
- public string Name { get; set; }
- public delegate void CollectionHandler(object source, CollectionHandlerEventArgs args);
- // происходит при добавлении нового элемента или при удалении элемента из коллекции
- public event CollectionHandler CollectionCountChanged;
- public void Add(int key, Pair valuee)
- {
- OnCollectionChanged(this, new CollectionHandlerEventArgs(this.Name, "ADD", valuee));
- base.Add(key, valuee);
- }
- //обработчик события CollectionCountChanged
- public void OnCollectionChanged(object source, CollectionHandlerEventArgs args)
- {
- if (CollectionCountChanged != null)
- CollectionCountChanged(source, args);
- }
- }
Add Comment
Please, Sign In to add comment