/// <summary>
        /// Determines whether the specified <see cref="System.Object"/> is equal to this instance.
        /// </summary>
        /// <param name="obj">The <see cref="System.Object"/> to compare with this instance.</param>
        /// <returns>
        ///     <c>true</c> if the specified <see cref="System.Object"/> is equal to this instance; otherwise, <c>false</c>.
        /// </returns>
        public override bool Equals(object obj)
        {
            CollectionObservationHandle other = obj as CollectionObservationHandle;

            return(other != null &&
                   this.PropertyChangedHandle.Equals(other.PropertyChangedHandle, false) &&
                   this.Callback.Equals(other.Callback));
        }
Exemple #2
0
        /// <summary>
        /// Monitors an INotifyCollectionChanged property and prints out any changes in the console using Debug.WriteLine(...).
        /// </summary>
        /// <param name="source">The source object that contains the property to monitor.</param>
        /// <param name="path">The path to the property to monitor.</param>
        /// <param name="announceMonitorBegin">if set to <c>true</c> an anouncement is made using Debug.WriteLine(...) when this method is called.</param>
        /// <returns>
        /// The CollectionObservationHandle that is used to monitor the specified collection property.
        /// </returns>
        public static CollectionObservationHandle MonitorCollection(object source, string path, bool announceMonitorBegin = true)
        {
            if (announceMonitorBegin)
            {
                Console.WriteLine("Monitoring collection property path \"{0}\" of source \"{1}\".", path, source);
            }

            return(CollectionObservationHandle.GetDistinctInstance(source, path, CollectionChangeCallback));
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="CollectionObservationCallbackArgs"/> class.
 /// </summary>
 /// <param name="handle">The CollectionObservationHandle instance that is assiciated with the callback.</param>
 /// <param name="notifyCollectionChangedEventArgs">The <see cref="System.Collections.Specialized.NotifyCollectionChangedEventArgs"/> instance containing the event data.</param>
 public CollectionObservationCallbackArgs(CollectionObservationHandle handle, NotifyCollectionChangedEventArgs notifyCollectionChangedEventArgs)
 {
     this.ChangeType = ChangeType.CollectionChanged;
     this.Handle     = handle;
     this.NotifyCollectionChangedEventArgs = notifyCollectionChangedEventArgs;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="CollectionObservationCallbackArgs"/> class.
 /// </summary>
 /// <param name="handle">The CollectionObservationHandle instance that is assiciated with the callback.</param>
 /// <param name="propertyChangedCallbackArgs">The PropertyChangedCallbackArgs instance that was caused by a property change.</param>
 public CollectionObservationCallbackArgs(CollectionObservationHandle handle, PropertyChangedCallbackArgs propertyChangedCallbackArgs)
 {
     this.ChangeType = ChangeType.PropertyChanged;
     this.Handle     = handle;
     this.PropertyChangedCallbackArgs = propertyChangedCallbackArgs;
 }