예제 #1
0
        private void Resort()
        {
            if (this.m_Sorter != null)
            {
                lock (this.m_Matches.SyncRoot)
                {
                    ArrayList unsorted = this.m_Matches;
                    this.m_Matches = new ArrayList(unsorted.Count);

                    _SortedList sortThese = new _SortedList(this.m_Sorter, true);
                    foreach (ICpMedia obj in unsorted)
                    {
                        sortThese.Set(this.m_Matches, obj, false);
                        //this.SortedInsert(obj);
                    }
                }

                if (this.OnMatchesCleared != null)
                {
                    this.OnMatchesCleared(this, (IList) EmptyList.Clone());
                }

                if (this.OnMatchesAdded != null)
                {
                    this.OnMatchesAdded(this, (IList) this.m_Matches.Clone());
                }
            }
        }
예제 #2
0
 /// <summary>
 /// Initializes all fields.
 /// </summary>
 /// <param name="sorter"></param>
 /// <param name="al"></param>
 private void Init(IComparer sorter, ArrayList al)
 {
     this.Cache  = al;
     this.Sorter = new _SortedList(sorter, false);
     this.Lock   = new ReaderWriterLock();
 }
예제 #3
0
        /// <summary>
        /// <see cref="CpMediaContainer.NotifySpidersAdd"/> calls this
        /// method to indicate that a container's contents have changed. 
        /// Upon exiting this method, the
        /// CdsSpider acknowledges that the container has changed
        /// and that the container has no obligation to keep its
        /// references to child objects any longer. 
        /// </summary>
        /// <param name="thisChanged">the container that has changed</param>
        /// <param name="addThese">
        /// A reliable listing of new matches for the container's current state.
        /// Each element will be a strong reference to an <see cref="ICpMedia"/> object.
        /// Assume that the container has already filtered the results so that
        /// addThese only contains elements that match the comparer for this spider.
        /// </param>
        internal void NotifySinkAdd(CpMediaContainer thisChanged, ArrayList addThese)
        {
            bool eventAdded = false;
            lock (this.m_Matches.SyncRoot)
            {
                if (thisChanged == this.MonitorThis)
                {
                    ExpectingResults = false;
                    if (addThese.Count > 0)
                    {
                        if ((this.m_Matches.Count == 0))
                        {
                            this.m_Matches = new ArrayList(addThese.Count);
                        }

                        if (this.m_Sorter != null)
                        {
                            // perform a sorted insert for each item
                            _SortedList sortThese = new _SortedList(this.m_Sorter, true);
                            foreach (ICpMedia obj in addThese)
                            {
                                sortThese.Set(this.m_Matches, obj, false);
                            }
                        }
                        else
                        {
                            this.m_Matches.AddRange((ICollection) addThese);
                        }

                        eventAdded = true;
                    }
                }
            }

            if (eventAdded)
            {
                if (this.OnMatchesAdded != null)
                {
                    this.OnMatchesAdded (this, addThese);
                }
            }
        }
예제 #4
0
		/// <summary>
		/// Initializes all fields.
		/// </summary>
		/// <param name="sorter"></param>
		/// <param name="al"></param>
		private void Init(IComparer sorter, ArrayList al)
		{
			this.Cache = al;
			this.Sorter = new _SortedList(sorter, false);
			this.Lock = new ReaderWriterLock();
		}