private void RegisterExitEvent() { if (!_eventRegistered) { var property = Type.GetType("System.AppDomain").GetRuntimeProperty("CurrentDomain"); var currentDomain = property.GetValue(null); EventUtilities.RegisterEvent(currentDomain, "ProcessExit", (sender, args) => WriteConfiguration()); _eventRegistered = true; } }
private void TrackCollection() { if (InternalCollection is INotifyCollectionChanged items) { var collection = items; _itemsChangedHandler = EventUtilities.RegisterEvent <TrackableCollection <TItem>, NotifyCollectionChangedEventHandler, NotifyCollectionChangedEventArgs>( this, h => collection.CollectionChanged += h, h => collection.CollectionChanged -= h, h => (o, e) => h(o, e), (subscriber, s, e) => subscriber.OnOriginalCollectionChanged(s, e)); } }
private void RegisterEvent(TItem item) { if (_events.ContainsKey(item)) { return; } if (item is INotifyPropertyChanged i) { var handler = EventUtilities.RegisterEvent <TrackableCollection <TItem>, PropertyChangedEventHandler, PropertyChangedEventArgs>( this, h => i.PropertyChanged += h, h => i.PropertyChanged -= h, h => (o, e) => h(o, e), (subscriber, s, e) => subscriber.OnCollectionItemPropertyChanged(s, e)); _events.Add(item, handler); } }