using System; namespace Unity.VisualScripting { public sealed class MergedGraphElementCollection : MergedKeyedCollection, INotifyCollectionChanged { public event Action ItemAdded; public event Action ItemRemoved; public event Action CollectionChanged; public override void Include(IKeyedCollection collection) { base.Include(collection); var graphElementCollection = collection as IGraphElementCollection; if (graphElementCollection != null) { graphElementCollection.ItemAdded += (element) => ItemAdded?.Invoke(element); graphElementCollection.ItemRemoved += (element) => ItemRemoved?.Invoke(element); graphElementCollection.CollectionChanged += () => CollectionChanged?.Invoke(); } } } }