Exemple #1
0
        /// <summary>
        /// Gets a collection providing the message set that pass the specified filter.
        /// </summary>
        /// <param name="filter">Filter to apply.</param>
        /// <returns>The filtered message collection.</returns>
        public FilteredLogMessageCollection <TMessage> GetFilteredCollection(ILogMessageCollectionFilter <TMessage> filter)
        {
            var collection = new FilteredLogMessageCollection <TMessage>(this, filter);

            mFilteredCollections.Add(new WeakReference <FilteredLogMessageCollection <TMessage> >(collection));
            return(collection);
        }
Exemple #2
0
 /// <summary>
 /// Unregisters the specified filtered collection, so it does not receive any further notifications
 /// when the unfiltered collection changes.
 /// </summary>
 /// <param name="collection">The filtered collection to unregister.</param>
 internal void UnregisterFilteredCollection(FilteredLogMessageCollection <TMessage> collection)
 {
     for (int i = 0; i < mFilteredCollections.Count; i++)
     {
         if (mFilteredCollections[i].TryGetTarget(out var other))
         {
             if (ReferenceEquals(collection, other))
             {
                 mFilteredCollections.RemoveAt(i--);
             }
         }
         else
         {
             // the filtered collection was collected
             // => clean up
             mFilteredCollections.RemoveAt(i--);
         }
     }
 }