public ClrMemberToken(object objectToObserve, string propertyName, string remainingPath, Action <object, string> callback, IPathNavigator pathNavigator) : base(objectToObserve, propertyName, remainingPath, callback, pathNavigator) { _actualHandler = CurrentTarget_PropertyChanged; _weakHandler = new WeakEventProxy <PropertyChangedEventArgs>(_actualHandler); _weakHandlerWrapper = _weakHandler.Handler; AcquireTarget(objectToObserve); }
/// <summary> /// Initializes a new instance of the <see cref="ClrMemberToken"/> class. /// </summary> /// <param name="objectToObserve">The object to observe.</param> /// <param name="propertyName">The property path.</param> /// <param name="remainingPath">The remaining path.</param> /// <param name="callback">The callback.</param> /// <param name="pathNavigator">The path navigator.</param> public ClrMemberToken(object objectToObserve, string propertyName, string remainingPath, Action<object, string> callback, IPathNavigator pathNavigator) : base(objectToObserve, propertyName, remainingPath, callback, pathNavigator) { _actualHandler = CurrentTarget_PropertyChanged; _weakHandler = new WeakEventProxy<PropertyChangedEventArgs>(_actualHandler); _weakHandlerWrapper = _weakHandler.Handler; AcquireTarget(objectToObserve); }
public WeakEventSubscriber(EventPublisher publisher) { _publisher = publisher; // Create the event handlers. Note that these must be kept as member-level references, // so that they are coupled to the class lifetime rather than the current scope - or else // no one would reference the event handler (since the WeakEventProxy just keeps // a weak reference to it)! _eventHandler = EventPublisher_EventRaised; _WeakEventProxy = new WeakEventProxy <EventArgs>(_eventHandler); _publisher.EventRaised += _WeakEventProxy.Handler; }
/// <summary> /// Initializes a new instance of the <see cref="BindingListAdapter<TElement>"/> class. /// </summary> /// <param name="source">The source.</param> /// <param name="dispatcher">The dispatcher.</param> public BindingListAdapter(IBindableCollection <TElement> source, IDispatcher dispatcher) : base(dispatcher) { source.ShouldNotBeNull("source"); _originalSource = source; _eventHandler = Source_CollectionChanged; _weakHandler = new WeakEventProxy <NotifyCollectionChangedEventArgs>(_eventHandler); _sortDirection = ListSortDirection.Ascending; WireInterceptor(_originalSource); _propertyDescriptors = new Dictionary <string, PropertyDescriptor>(); var properties = TypeDescriptor.GetProperties(typeof(TElement)); foreach (PropertyDescriptor descriptor in properties) { if (descriptor != null && descriptor.Name != null) { _propertyDescriptors[descriptor.Name] = descriptor; } } }
/// <summary> /// Initializes a new instance of the <see cref="CollectionChangeObserver"/> class. /// </summary> /// <param name="callback">The callback.</param> public CollectionChangeObserver(EventHandler <NotifyCollectionChangedEventArgs> callback) { _weakEvent = new WeakEventProxy <NotifyCollectionChangedEventArgs>(callback); _callback = new NotifyCollectionChangedEventHandler(callback); }
/// <summary> /// Initializes a new instance of the <see cref="PropertyChangeObserver"/> class. /// </summary> /// <param name="callback">The callback.</param> public PropertyChangeObserver(EventHandler <PropertyChangedEventArgs> callback) { _callback = callback; _weakHandler = new WeakEventProxy <PropertyChangedEventArgs>(callback); }
public WeakEventSubscriber(EventPublisher publisher) { _publisher = publisher; // Create the event handlers. Note that these must be kept as member-level references, // so that they are coupled to the class lifetime rather than the current scope - or else // no one would reference the event handler (since the WeakEventProxy just keeps // a weak reference to it)! _eventHandler = EventPublisher_EventRaised; _WeakEventProxy = new WeakEventProxy<EventArgs>(_eventHandler); _publisher.EventRaised += _WeakEventProxy.Handler; }