Esempio n. 1
0
        void ICombinedSearchResultInternal.Init(ISourceSearchResultInternal[] results, CancellationToken cancellation)
        {
            IMessage lastMessage = null;

            foreach (var m in (new MessagesContainers.SimpleMergingCollection(
                                   results.Select(r => r.CreateMessagesSnapshot()))).Forward(0, int.MaxValue))
            {
                if (cancellation.IsCancellationRequested)
                {
                    break;
                }
                var msg = m.Message.Message;
                if (lastMessage != null && MessagesComparer.Compare(lastMessage, msg) == 0)
                {
                    continue;
                }
                ICombinedSourceSearchResultInternal rslt;
                if (!logSourcesResults.TryGetValue(msg.LogSource, out rslt))
                {
                    logSourcesResults.Add(msg.LogSource, rslt = objectsFactory.CreateCombinedSourceSearchResult(msg.LogSource));
                }
                if (!rslt.Add(msg))
                {
                    continue;
                }
                lastMessage = msg;
            }
        }
Esempio n. 2
0
        public static Tuple <int, int> FindBookmark(this IReadOnlyList <IBookmark> items, IBookmark bmk)
        {
            if (bmk == null)
            {
                return(null);
            }
            int cmp(IBookmark b) => MessagesComparer.Compare(b, bmk);

            int lowerBound = items.BinarySearch(0, items.Count, e => cmp(e) < 0);
            int upperBound = items.BinarySearch(lowerBound, items.Count, e => cmp(e) <= 0);

            return(Tuple.Create(lowerBound, upperBound));
        }
Esempio n. 3
0
 int IComparer <EnumMessagesHelper> .Compare(EnumMessagesHelper x, EnumMessagesHelper y)
 {
     return(MessagesComparer.Compare(x.Peek(), y.Peek()));
 }