コード例 #1
0
        public LogSourcesDialogViewModel(ILogSourceService logSourceService)
        {
            _sources = CreateProperty <IList <ILogSource> >(nameof(Sources));

            logSourceService.Sources.AsItemsBehaviorObservable().Subscribe(_sources);

            CloseCommand = Command.Create((object o) => Close());
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        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();
        }
コード例 #4
0
 public LogFileImportService(ILogSourceService logSourceService, IList <ILogFormat> logFormats, IDialogService dialogService)
 {
     _logSourceService = logSourceService;
     _logFormats       = logFormats;
     _dialogService    = dialogService;
 }