public LogSourceLevelFilter(ILogSourceService logSourceService, ILogFilterService logFilterService) { _thisLock = new object(); _sourceLevels = new Dictionary <ILogSource, LogLevel>(); _filter = new BehaviorSubject <Func <LogEvent, bool> >(LogFilter.PassAll); logFilterService.AddFilter(_filter); _sourcesSubscription = logSourceService.Sources.AsItemsBehaviorObservable().Subscribe(OnSourcesChanged); }
public LogFilterResultsService(ILogSourceService logSourceService, ILogFilterService logFilterService) { _logEvents = new ObservableCowList <LogEvent>(); Result = _logEvents; var sourceLogEvents = logSourceService.LogEvents.AsBehaviorObservable().Publish(); var filterChanges = logFilterService.Filter.Publish(); var sourceResetEvents = sourceLogEvents.Where(e => e.Action == NotifyListChangedAction.Reset).Select(e => e.Items); Observable.Merge( Observable.WithLatestFrom( sourceResetEvents, filterChanges, (items, filter) => (items, filter) ), Observable.WithLatestFrom( filterChanges, sourceLogEvents.Select(e => e.Items), (filter, items) => (items, filter) ) ) .Select(x => { (var items, var filter) = x; return(Observable.Concat( InvokeFilter(NotifyListChangedAction.Reset, items, filter), sourceLogEvents .TakeWhile(e => e.Action == NotifyListChangedAction.Add) .Select(e => InvokeFilter(e.Action, e.NewItems, filter)) .SelectMany(a => a) )); }) .Switch().Subscribe(x => { (var action, var items) = x; switch (action) { case NotifyListChangedAction.Add: _logEvents.Add(items); break; case NotifyListChangedAction.Reset: _logEvents.Reset(items); break; default: throw new NotSupportedException(); } }); filterChanges.Connect(); sourceLogEvents.Connect(); }
public SearchPanelViewModel(ILogFilterService logFilterService, ILogsViewService logsViewService) { LogsViewService = logsViewService; _selectedLogLevel = CreateProperty(nameof(SelectedLogLevel), LogLevel.All); var levelFilter = _selectedLogLevel.Select(CreateLogLevelFilter); logFilterService.AddFilter(levelFilter); _query = CreateProperty <string>(nameof(Query)); var queryFilter = _query.Select(CreateQueryFilter).DistinctUntilChanged(); logFilterService.AddFilter(queryFilter); }