Inheritance: AbstractNotifyPropertyChanged, ILinesVisualisation, IPersistentView
        public IDisposable Create(TailViewModel tailView, bool loadDefaults)
        {
            if (tailView == null) throw new ArgumentNullException(nameof(tailView));

            var logger = _loggerFactory.Create<TailViewStateController>();
            return new TailViewStateController(tailView,_stateBucketService, _schedulerProvider, _tailViewStateRestorer, logger, loadDefaults);
        }
Exemplo n.º 2
0
 public void Restore(TailViewModel view,TailViewState tailviewstate)
 {
     _logger.Info("Applying {0} saved search settings  for {1} ", tailviewstate.SearchItems.Count(), view.Name);
     var searches = tailviewstate.SearchItems.Select(_searchStateToMetadataMapper.Map);
     view.SearchMetadataCollection.Add(searches);
     view.SearchCollection.Select(tailviewstate.SelectedSearch);
     _logger.Info("DONE: Applied {0} search settings for {1} ", tailviewstate.SearchItems.Count(), view.Name);
 }
Exemplo n.º 3
0
        public void Restore(TailViewModel view, TailViewState tailviewstate)
        {
            _logger.Info("Applying {0} saved search settings  for {1} ", tailviewstate.SearchItems.Count(), view.Name);
            var searches = tailviewstate.SearchItems.Select(_searchStateToMetadataMapper.Map);

            view.SearchMetadataCollection.Add(searches);
            view.SearchCollection.Select(tailviewstate.SelectedSearch);
            _logger.Info("DONE: Applied {0} search settings for {1} ", tailviewstate.SearchItems.Count(), view.Name);
        }
        public TailViewStateController([NotNull] TailViewModel tailView, IStateBucketService stateBucketService, ISchedulerProvider schedulerProvider, ITailViewStateRestorer tailViewStateRestorer, ILogger logger, bool loadDefaults)
        {
            if (tailView == null) throw new ArgumentNullException(nameof(tailView));

            _tailView = tailView;

            var converter = new TailViewToStateConverter();

            bool loadingSettings=false;
            const string type = "TailView";
            logger.Info("Loading state for {0}", tailView.Name);

            //Load state

            if (loadDefaults)
            {
                stateBucketService
                    .Lookup(type, tailView.Name)
                    .IfHasValue(tailviewstate =>
                    {
                        schedulerProvider.Background.Schedule(() =>
                        {
                            try
                            {
                                loadingSettings = true;
                                tailViewStateRestorer.Restore(tailView, tailviewstate);
                            }
                            finally
                            {
                                loadingSettings = false;
                            }

                        });
                    });
            }

            //write latest to file when something triggers a change
            var selectedChanged = tailView.SearchCollection
                    .WhenValueChanged(sc=>sc.Selected,false)
                    .Where(vm => vm !=null)
                    .Select(vm=>vm.Text);

            var metaChanged = _tailView.SearchMetadataCollection.Metadata.Connect()
                    .ToCollection()
                    .Select(metaData => metaData.ToArray());

            var writer = selectedChanged.CombineLatest(metaChanged,(selected, metadata)=>new { selected , metadata })
                        .Where(_=> !loadingSettings)
                        .Throttle(TimeSpan.FromMilliseconds(250))
                        .Select(x => converter.Convert(_tailView.Name, x.selected, x.metadata))
                    .Subscribe(state =>
                    {
                        stateBucketService.Write(type, tailView.Name, state);
                    });

            _cleanUp = new CompositeDisposable(writer);
        }
Exemplo n.º 5
0
        public IDisposable Create([NotNull] TailViewModel tailView)
        {
            if (tailView == null)
            {
                throw new ArgumentNullException(nameof(tailView));
            }

            var logger = _loggerFactory.Create <TailViewStateController>();

            return(new TailViewStateController(tailView, _stateBucketService, _schedulerProvider, _tailViewStateRestorer, logger));
        }
Exemplo n.º 6
0
 public TailViewPersister(TailViewModel tailView, ITailViewStateRestorer tailViewStateRestorer)
 {
     _tailView = tailView;
     _tailViewStateRestorer = tailViewStateRestorer;
 }
Exemplo n.º 7
0
        public TailViewStateController([NotNull] TailViewModel tailView,
                                       IStateBucketService stateBucketService,
                                       ISchedulerProvider schedulerProvider,
                                       ISearchStateToMetadataMapper searchStateToMetadataMapper,
                                       ILogger logger)
        {
            if (tailView == null)
            {
                throw new ArgumentNullException(nameof(tailView));
            }

            _tailView = tailView;

            bool         loadingSettings = false;
            const string type            = "TailView";

            logger.Info("Loading state for {0}", tailView.Name);
            stateBucketService
            .Lookup(type, tailView.Name)
            .Convert(state =>
            {
                var converter = new TailViewToStateConverter();
                return(converter.Convert((State)state));
            }).IfHasValue(tailviewstate =>
            {
                schedulerProvider.Background.Schedule(() =>
                {
                    try
                    {
                        loadingSettings = true;
                        logger.Info("Applying {0} saved search settings  for {1} ", tailviewstate.SearchItems.Count(), tailView.Name);
                        var searches = tailviewstate.SearchItems.Select(searchStateToMetadataMapper.Map);
                        _tailView.SearchMetadataCollection.Add(searches);
                        tailView.SearchCollection.Select(tailviewstate.SelectedSearch);
                        logger.Info("DONE: Applied {0} search settings for {1} ", tailviewstate.SearchItems.Count(), tailView.Name);
                    }
                    finally
                    {
                        loadingSettings = false;
                    }
                });
            });

            var selectedChanged = tailView.SearchCollection
                                  .WhenValueChanged(sc => sc.Selected, false)
                                  .Select(vm => vm.Text);

            var metaChanged = _tailView.SearchMetadataCollection.Metadata.Connect()
                              .ToCollection()
                              .Select(metaData => metaData.ToArray());

            var writer = selectedChanged.CombineLatest(metaChanged, (selected, metadata) => new { selected, metadata })
                         .Where(_ => !loadingSettings)
                         .Throttle(TimeSpan.FromMilliseconds(250))
                         .Select(x => Convert(_tailView.Name, x.selected, x.metadata))
                         .Subscribe(state =>
            {
                stateBucketService.Write(type, tailView.Name, state);
            });

            _cleanUp = new CompositeDisposable(writer);
        }
Exemplo n.º 8
0
 public TailViewPersister(TailViewModel tailView, ITailViewStateRestorer tailViewStateRestorer)
 {
     _tailView = tailView;
     _tailViewStateRestorer = tailViewStateRestorer;
 }
Exemplo n.º 9
0
 public TailViewPersister(TailViewModel tailView)
 {
     _tailView = tailView;
 }
Exemplo n.º 10
0
        public TailViewStateController([NotNull] TailViewModel tailView, IStateBucketService stateBucketService, ISchedulerProvider schedulerProvider, ITailViewStateRestorer tailViewStateRestorer, ILogger logger, bool loadDefaults)
        {
            if (tailView == null)
            {
                throw new ArgumentNullException(nameof(tailView));
            }

            var tailView1 = tailView;


            var converter = new TailViewToStateConverter();

            bool         loadingSettings = false;
            const string type            = "TailView";

            logger.Info("Loading state for {0}", tailView.Name);

            //Load state

            if (loadDefaults)
            {
                stateBucketService
                .Lookup(type, tailView.Name)
                .IfHasValue(tailviewstate =>
                {
                    schedulerProvider.Background.Schedule(() =>
                    {
                        try
                        {
                            loadingSettings = true;
                            tailViewStateRestorer.Restore(tailView, tailviewstate);
                        }
                        finally
                        {
                            loadingSettings = false;
                        }
                    });
                });
            }

            //write latest to file when something triggers a change
            var selectedChanged = tailView.SearchCollection
                                  .WhenValueChanged(sc => sc.Selected, false)
                                  .Where(vm => vm != null)
                                  .Select(vm => vm.Text);

            var metaChanged = tailView1.SearchMetadataCollection.Metadata.Connect()
                              .ToCollection()
                              .Select(metaData => metaData.ToArray());

            var writer = selectedChanged.CombineLatest(metaChanged, (selected, metadata) => new { selected, metadata })
                         .Where(_ => !loadingSettings)
                         .Throttle(TimeSpan.FromMilliseconds(250))
                         .Select(x => converter.Convert(tailView1.Name, x.selected, x.metadata))
                         .Subscribe(state =>
            {
                stateBucketService.Write(type, tailView.Name, state);
            });

            _cleanUp = new CompositeDisposable(writer);
        }
Exemplo n.º 11
0
 public void Restore(TailViewModel view, State state)
 {
     var converter = new TailViewToStateConverter();
     Restore(view,converter.Convert(state));
 }
Exemplo n.º 12
0
        public void Restore(TailViewModel view, State state)
        {
            var converter = new TailViewToStateConverter();

            Restore(view, converter.Convert(state));
        }