Ejemplo n.º 1
0
        public void OnCompleteIsInvokedWhenFeederIsDisposed()
        {
            bool completed = false;

            var subscriber = _source.LimitSizeTo(10)
                             .Finally(() => completed = true)
                             .Subscribe(updates => { Console.WriteLine(); });

            _source.Dispose();

            Assert.IsTrue(completed, "Completed has not been called");
        }
Ejemplo n.º 2
0
 public void Initialise()
 {
     _scheduler   = new TestScheduler();
     _source      = new SourceList <Person>();
     _sizeLimiter = _source.LimitSizeTo(10, _scheduler).Subscribe();
     _results     = _source.Connect().AsAggregator();
 }
		public void Initialise()
		{
			_scheduler = new TestScheduler();
			_source = new SourceList<Person>();
			_sizeLimiter = _source.LimitSizeTo(10, _scheduler).Subscribe();
			_results = _source.Connect().AsAggregator();

		}
Ejemplo n.º 4
0
 public void Initialise()
 {
     _scheduler = new TestScheduler();
     _source = new SourceList<Person>();
     _sizeLimiter = _source.LimitSizeTo(10, _scheduler).Subscribe();
     _results = _source.Connect()
         .Sort(SortExpressionComparer<Person>.Ascending(p=>p.Name))
         .AsAggregator();
 }
Ejemplo n.º 5
0
 public void Initialise()
 {
     _scheduler   = new TestScheduler();
     _source      = new SourceList <Person>();
     _sizeLimiter = _source.LimitSizeTo(10, _scheduler).Subscribe();
     _results     = _source.Connect()
                    .Sort(SortExpressionComparer <Person> .Ascending(p => p.Name))
                    .AsAggregator();
 }
Ejemplo n.º 6
0
        public SelectionMonitor(ILogger logger, ISchedulerProvider schedulerProvider)
        {
            _logger            = logger;
            _schedulerProvider = schedulerProvider;
            Selected           = _selected.AsObservableList();

            _cleanUp = new CompositeDisposable(
                _selected,
                _recentlyRemovedFromVisibleRange,
                _controlSubscriber,
                Selected,
                //keep recent items only up to a certain number
                _recentlyRemovedFromVisibleRange.LimitSizeTo(100).Subscribe());
        }
Ejemplo n.º 7
0
        public LogEntryService(ILogger logger)
        {
            _logger = logger;
            Items   = _source.AsObservableList();

            var loader = ReactiveLogAppender.LogEntryObservable
                         .Buffer(TimeSpan.FromMilliseconds(250))
                         .Synchronize(_locker)
                         .Subscribe(_source.AddRange);

            //limit size of cache to prevent too many items being created
            var sizeLimiter = _source.LimitSizeTo(10000).Subscribe();

            // alternatively could expire by time
            //var timeExpirer = _source.ExpireAfter(le => TimeSpan.FromSeconds(le.Level == LogLevel.Debug ? 5 : 60), TimeSpan.FromSeconds(5), TaskPoolScheduler.Default)
            //                            .Subscribe(removed => logger.Debug("{0} log items have been automatically removed", removed.Count()));

            _disposer = new CompositeDisposable(sizeLimiter, _source, loader);
            logger.Info("Log cache has been constructed");
        }
Ejemplo n.º 8
0
        public SelectionMonitor(ILogger logger)
        {
            _logger  = logger;
            Selected = _selected.AsObservableList();

            var selectionLogger = _selected.Connect()
                                  .ToCollection()
                                  .Subscribe(collection =>
            {
                logger.Debug($"{collection.Count} selected: {collection.Select(l=>l.Text).ToDelimited(Environment.NewLine)} ");
            });

            _cleanUp = new CompositeDisposable(
                _selected,
                _recentlyRemovedFromVisibleRange,
                _controlSubscriber,
                Selected,
                selectionLogger,
                //keep recent items only up to a certain number
                _recentlyRemovedFromVisibleRange.LimitSizeTo(100).Subscribe());
        }