예제 #1
0
        /// <summary>
        /// Adds all events from the specified collection to the end of this one.
        /// </summary>
        /// <param name="eventsToMerge">Events to merge.</param>
        /// <param name="fromStart">true - copy from start of collection, false - copy from end of collection.</param>
        /// <param name="maxEventsToMerge">Maximum events to merge.</param>
        public StackHashEventPackageCollection MergeEvents(StackHashEventPackageCollection eventsToMerge, bool fromStart, long maxEventsToMerge)
        {
            if (eventsToMerge == null)
            {
                throw new ArgumentNullException("eventsToMerge");
            }

            long numEvents = maxEventsToMerge;

            if (numEvents > eventsToMerge.Count)
            {
                numEvents = eventsToMerge.Count;
            }

            if (fromStart)
            {
                for (int i = 0; i < numEvents; i++)
                {
                    if (eventsToMerge[i].RowNumber > this.MaximumRowNumber)
                    {
                        this.MaximumRowNumber = eventsToMerge[i].RowNumber;
                    }
                    if (eventsToMerge[i].RowNumber < this.MinimumRowNumber)
                    {
                        this.MinimumRowNumber = eventsToMerge[i].RowNumber;
                    }

                    this.Add(eventsToMerge[i]);
                }
            }
            else
            {
                // Merge at the start of this array - but only the specified number of entries.
                int added = 0;
                for (int i = eventsToMerge.Count - 1; i >= 0; i--)
                {
                    if (added >= maxEventsToMerge)
                    {
                        break;
                    }
                    if (this.FindEventPackage(eventsToMerge[i].EventData.Id, eventsToMerge[i].EventData.EventTypeName) == null)
                    {
                        this.InsertItem(0, eventsToMerge[i]);
                        added++;
                    }
                }
            }
            return(this);
        }
예제 #2
0
        public int CompareTo(object obj)
        {
            StackHashEventPackageCollection events = obj as StackHashEventPackageCollection;

            if (events.Count != this.Count)
            {
                return(-1);
            }

            foreach (StackHashEventPackage thisEventPackage in this)
            {
                StackHashEventPackage matchingEventInfo =
                    events.FindEventPackage(thisEventPackage.EventData.Id, thisEventPackage.EventData.EventTypeName);

                if (matchingEventInfo == null)
                {
                    return(-1);
                }

                // Check the event data and the event info and cab data.
                if (matchingEventInfo.EventData.CompareTo(thisEventPackage.EventData) != 0)
                {
                    return(-1);
                }

                if (matchingEventInfo.EventInfoList.CompareTo(thisEventPackage.EventInfoList) != 0)
                {
                    return(-1);
                }

                if (matchingEventInfo.Cabs.CompareTo(thisEventPackage.Cabs) != 0)
                {
                    return(-1);
                }
            }

            // Must be a match.
            return(0);
        }