Exemple #1
0
        async Task Worker()
        {
            await startEvent.Task;
            long startPosition      = 0;
            bool startPositionValid = false;

            if (options.StartPositions != null)
            {
                startPositionValid = options.StartPositions.TryGetValue(logSource, out startPosition);
            }
            using (var cancellation = CancellationTokenSource.CreateLinkedTokenSource(cancellations.ToArray()))
                using (var progressSink = new Progress.MultiplexingProgressEventsSink(progressSinks))
                {
                    await logSource.Provider.Search(
                        new SearchAllOccurencesParams(options.Filters, options.SearchInRawText,
                                                      startPositionValid ? startPosition : new long?()),
                        (msg) =>
                    {
                        Func <SearchResultMessage, bool> callback;
                        var callbackKey = new NullableDictionaryKey <IFilter>(msg.FilteringResult.Filter);
                        if (callbacks.TryGetValue(callbackKey, out callback) && !callback(msg))
                        {
                            callbacks.Remove(callbackKey);
                        }
                        return(callbacks.Count > 0);
                    },
                        cancellation.Token,
                        progress : progressSink
                        );
                }
        }
Exemple #2
0
 int IEqualityComparer <NullableDictionaryKey <T> > .GetHashCode(NullableDictionaryKey <T> obj)
 {
     return(obj.Value?.GetHashCode() ?? 0);
 }
Exemple #3
0
 bool IEqualityComparer <NullableDictionaryKey <T> > .Equals(NullableDictionaryKey <T> x, NullableDictionaryKey <T> y)
 {
     return(x.Value == y.Value);
 }