public void Initialise()
      {
          _source = new SourceList<Person>();
          _controller = new VirtualisingController(new VirtualRequest(0,25));
          _results = _source.Connect().Virtualise(_controller).AsAggregator();
 
      }
예제 #2
0
        public void MyTestInitialize()
        {
            _scheduler = new TestScheduler();
            _source = new SourceList<Person>();
            _results = _source.Connect().Buffer(TimeSpan.FromMinutes(1),_scheduler).FlattenBufferResult().AsAggregator();

        }
 public void MyTestInitialize()
 {
     _pausingSubject = new Subject<bool>();
     _scheduler = new TestScheduler();
     _source = new SourceList<Person>();
     _results = _source.Connect().BufferIf(_pausingSubject,TimeSpan.FromMinutes(1), _scheduler).AsAggregator();
 }
예제 #4
0
        public SortMutableFixture()
        {
            _source         = new SourceList <Person>();
            _changeComparer = new BehaviorSubject <IComparer <Person> >(_comparer);
            _resort         = new Subject <Unit>();

            _results = _source.Connect().Sort(_changeComparer, resetThreshold: 25, resort: _resort).AsAggregator();
        }
예제 #5
0
        public TransformManyFixture()
        {
            _source = new SourceList <PersonWithRelations>();

            _results = _source.Connect()
                       .TransformMany(p => p.Relations.RecursiveSelect(r => r.Relations))
                       .AsAggregator();
        }
예제 #6
0
        public void EachChangeInokesTheCallback()
        {
            var messages = new List <Change <Person> >();

            var messageWriter = _source
                                .Connect()
                                .ForEachChange(messages.Add)
                                .Subscribe();

            var people = new RandomPersonGenerator().Take(100);

            people.ForEach(_source.Add);


            Assert.AreEqual(100, messages.Count);
            messageWriter.Dispose();
        }
		public void Initialise()
		{
			_scheduler = new TestScheduler();
			_source = new SourceList<Person>();
			_sizeLimiter = _source.LimitSizeTo(10, _scheduler).Subscribe();
			_results = _source.Connect().AsAggregator();

		}
		public void Initialise()
		{
			_source = new SourceList<PersonWithRelations>();

			_results = _source.Connect().TransformMany(p => p.Relations.RecursiveSelect(r => r.Relations))
				//.IgnoreUpdateWhen((current, previous) => current.Name == previous.Name)
				.AsAggregator();
		}
        public TransformManyProjectionFixture()
        {
            _source = new SourceList <ClassWithNestedObservableCollection>();

            _results = _source.Connect()
                       .AutoRefreshOnObservable(self => self.Children.ToObservableChangeSet())
                       .TransformMany(parent => parent.Children.Select(c => new ProjectedNestedChild(parent, c)), new ProjectNestedChildEqualityComparer())
                       .AsObservableList();
        }
    /// <summary>
    /// Initializes a new instance of the <see cref="ReactiveRecyclerViewAdapter{TViewModel}"/> class.
    /// </summary>
    /// <param name="backingList">The backing list.</param>
    protected ReactiveRecyclerViewAdapter(IObservable <IChangeSet <TViewModel> > backingList)
    {
        _list = new SourceList <TViewModel>(backingList);

        _inner = _list
                 .Connect()
                 .ForEachChange(UpdateBindings)
                 .Subscribe();
    }
예제 #11
0
 public BatchFixture()
 {
     _scheduler = new TestScheduler();
     _source    = new SourceList <Person>();
     _results   = _source.Connect()
                  .Buffer(TimeSpan.FromMinutes(1), _scheduler)
                  .FlattenBufferResult()
                  .AsAggregator();
 }
예제 #12
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();
 }
예제 #13
0
        public void InvocationOnlyWhenChildIsInvoked()
        {
            bool invoked = false;

            var stream = _source.Connect()
                         .MergeMany(o => o.Observable)
                         .Subscribe(o => { invoked = true; });

            var item = new ObjectWithObservable(1);

            _source.Add(item);

            invoked.Should().BeFalse();

            item.InvokeObservable(true);
            invoked.Should().BeTrue();
            stream.Dispose();
        }
예제 #14
0
        public TransformManyRefreshFixture()
        {
            _source = new SourceList <PersonWithFriends>();

            _results = _source.Connect()
                       .AutoRefresh()
                       .TransformMany(p => p.Friends.RecursiveSelect(r => r.Friends))
                       .AsAggregator();
        }
예제 #15
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();
 }
        public void PreviewEventsAreCorrect()
        {
            var preview = _source.Preview().AsAggregator();
            var connect = _source.Connect().AsAggregator();

            _source.Edit(
                l =>
            {
                l.Add(1);
                _source.Edit(l2 => l2.Add(2));
                l.Remove(2);
                l.AddRange(new[] { 3, 4, 5 });
                l.Move(1, 0);
            });

            Assert.True(preview.Messages.SequenceEqual(connect.Messages));
            Assert.True(_source.Items.SequenceEqual(new[] { 3, 1, 4, 5 }));
        }
예제 #17
0
        public void InvocationOnlyWhenChildIsInvoked()
        {
            bool invoked = false;

            var stream = _source.Connect()
                         .MergeMany(o => o.Observable)
                         .Subscribe(o => { invoked = true; });

            var item = new ObjectWithObservable(1);

            _source.Add(item);

            Assert.IsFalse(invoked, "Error. The operator should not have been invoked");

            item.InvokeObservable(true);
            Assert.IsTrue(invoked, "The observable should have notified");
            stream.Dispose();
        }
예제 #18
0
 public void Initialise()
 {
     _source  = new SourceList <SubscribeableObject>();
     _results = new ChangeSetAggregator <SubscribeableObject>(
         _source.Connect().SubscribeMany(subscribeable =>
     {
         subscribeable.Subscribe();
         return(Disposable.Create(subscribeable.UnSubscribe));
     }));
 }
예제 #19
0
        public MainWindowBlocksService()
        {
            statusBarItemsSource
            .Connect()
            .Bind(out var statusBarItems)
            .Subscribe()
            .AddTo(Anchors);

            StatusBarItems = statusBarItems;
        }
 public void Initialise()
 {
     _source = new SourceList<SubscribeableObject>();
     _results = new ChangeSetAggregator<SubscribeableObject>(
         _source.Connect().SubscribeMany(subscribeable =>
         {
             subscribeable.Subscribe();
             return Disposable.Create(subscribeable.UnSubscribe);
         }));
 }
예제 #21
0
        public void IncludedWhenItemIsInOneSource()
        {
            _source.Add(_source1.Connect());
            _source.Add(_source2.Connect());
            _source1.Add(1);

            _results.Data.Count.Should().Be(1);
            _results.Data.Items.First().Should().Be(1);
        }
예제 #22
0
        public void IncludedWhenItemIsInOneSource()
        {
            _source.Add(_source1.Connect());
            _source.Add(_source2.Connect());
            _source1.Add(1);

            Assert.AreEqual(1, _results.Data.Count);
            Assert.AreEqual(1, _results.Data.Items.First());
        }
예제 #23
0
        public void AddAndRemoveLists()
        {
            _source1.AddRange(Enumerable.Range(1, 5));
            _source2.AddRange(Enumerable.Range(6, 5));
            _source3.AddRange(Enumerable.Range(100, 5));

            _source.Add(_source1.Connect());
            _source.Add(_source2.Connect());
            _source.Add(_source3.Connect());

            var result = Enumerable.Range(1, 5).Union(Enumerable.Range(6, 5)).Union(Enumerable.Range(100, 5));

            _results.Data.Count.Should().Be(15);
            _results.Data.Items.Should().BeEquivalentTo(result);

            _source.RemoveAt(1);
            _results.Data.Count.Should().Be(10);

            result = Enumerable.Range(1, 5).Union(Enumerable.Range(100, 5));
            _results.Data.Items.Should().BeEquivalentTo(result);
        }
예제 #24
0
        public Workspace()
        {
            mMonitoredCalls = new SourceCache <IMonitoredCall, int>(c => c.Call.InstrumentedCallId);
            mMethods        = new SourceCache <IInstrumentedMethod, int>(m => m.InstrumentedMethodId);
            mDocuments      = new SourceList <IWorkspaceDocument>();

            MonitoredCalls = mMonitoredCalls.Connect().RemoveKey();
            Methods        = mMethods.Connect().RemoveKey();
            Documents      = mDocuments.Connect();

            mDocuments.Add(MonitoringConfiguration);
        }
예제 #25
0
        public void CanResubscribe()
        {
            int created   = 0;
            int disposals = 0;

            //must have data so transform is invoked
            _source.Add(new Person("Name", 10));

            //Some expensive transform (or chain of operations)
            var longChain = _source.Connect().Transform(p => p).Do(_ => created++).Finally(() => disposals++).RefCount();

            var subscriber = longChain.Subscribe();

            subscriber.Dispose();

            subscriber = longChain.Subscribe();
            subscriber.Dispose();

            created.Should().Be(2);
            disposals.Should().Be(2);
        }
예제 #26
0
        public void AddAndRemoveLists()
        {
            _source1.AddRange(Enumerable.Range(1, 5));
            _source2.AddRange(Enumerable.Range(6, 5));
            _source3.AddRange(Enumerable.Range(100, 5));

            _source.Add(_source1.Connect());
            _source.Add(_source2.Connect());
            _source.Add(_source3.Connect());

            var result = Enumerable.Range(1, 5).Union(Enumerable.Range(6, 5)).Union(Enumerable.Range(100, 5));

            Assert.AreEqual(15, _results.Data.Count);
            CollectionAssert.AreEquivalent(result, _results.Data.Items);

            _source.RemoveAt(1);
            Assert.AreEqual(10, _results.Data.Count);

            result = Enumerable.Range(1, 5).Union(Enumerable.Range(100, 5));
            CollectionAssert.AreEquivalent(result, _results.Data.Items);
        }
예제 #27
0
        protected ComplexAuraAction()
        {
            var actionList = new ObservableCollectionExtended <IAuraAction>();

            actions
            .Connect()
            .DisposeMany()
            .Bind(actionList)
            .Subscribe()
            .AddTo(Anchors);
            Actions = actionList;
        }
예제 #28
0
        public SharedContext(
            [NotNull][Dependency(WellKnownSchedulers.UI)] IScheduler uiScheduler)
        {
            SystemTrigger = new ComplexAuraTrigger().AddTo(Anchors);

            auraList = new ObservableCollectionExtended <IEyeAuraViewModel>();
            tabsListSource
            .Connect()
            .DisposeMany()
            .Bind(auraList)
            .Subscribe(() => { }, Log.HandleUiException)
            .AddTo(Anchors);
        }
예제 #29
0
 /// <summary>
 /// Connects to the list, and converts the changes to another form
 ///
 /// Alas, I had to add the converter due to type inference issues
 /// </summary>
 /// <typeparam name="TSource">The type of the object.</typeparam>
 /// <typeparam name="TDestination">The type of the destination.</typeparam>
 /// <param name="source">The source.</param>
 /// <param name="conversionFactory">The conversion factory.</param>
 /// <returns></returns>
 /// <exception cref="System.ArgumentNullException">
 /// </exception>
 public static IObservable <IChangeSet <TDestination> > Cast <TSource, TDestination>([NotNull] this ISourceList <TSource> source,
                                                                                     [NotNull] Func <TSource, TDestination> conversionFactory)
 {
     if (source == null)
     {
         throw new ArgumentNullException(nameof(source));
     }
     if (conversionFactory == null)
     {
         throw new ArgumentNullException(nameof(conversionFactory));
     }
     return(source.Connect().Select(changes => changes.Transform(conversionFactory)));
 }
예제 #30
0
        /// <summary>
        /// Connects to the list, and converts the changes to another form
        ///
        /// Alas, I had to add the converter due to type inference issues.
        /// </summary>
        /// <typeparam name="TSource">The type of the object.</typeparam>
        /// <typeparam name="TDestination">The type of the destination.</typeparam>
        /// <param name="source">The source.</param>
        /// <param name="conversionFactory">The conversion factory.</param>
        /// <returns>An observable which emits that change set.</returns>
        public static IObservable <IChangeSet <TDestination> > Cast <TSource, TDestination>(this ISourceList <TSource> source, Func <TSource, TDestination> conversionFactory)
        {
            if (source is null)
            {
                throw new ArgumentNullException(nameof(source));
            }

            if (conversionFactory is null)
            {
                throw new ArgumentNullException(nameof(conversionFactory));
            }

            return(source.Connect().Cast(conversionFactory));
        }
예제 #31
0
        public void AddAndRemoveLists()
        {
            _source1.AddRange(Enumerable.Range(1, 5));
            _source2.AddRange(Enumerable.Range(6, 5));
            _source3.AddRange(Enumerable.Range(100, 5));

            _source.Add(_source1.Connect());
            _source.Add(_source2.Connect());
            _source.Add(_source3.Connect());

            var result = Enumerable.Range(1, 5);

            _results.Data.Count.Should().Be(5);
            _results.Data.Items.Should().BeEquivalentTo(result);

            _source2.Edit(
                innerList =>
            {
                innerList.Clear();
                innerList.AddRange(Enumerable.Range(3, 5));
            });

            result = Enumerable.Range(1, 2);
            _results.Data.Count.Should().Be(2);
            _results.Data.Items.Should().BeEquivalentTo(result);

            _source.RemoveAt(1);
            result = Enumerable.Range(1, 5);
            _results.Data.Count.Should().Be(5);
            _results.Data.Items.Should().BeEquivalentTo(result);

            _source.Add(_source2.Connect());
            result = Enumerable.Range(1, 2);
            _results.Data.Count.Should().Be(2);
            _results.Data.Items.Should().BeEquivalentTo(result);

            //remove root except
            _source.RemoveAt(0);
            result = Enumerable.Range(100, 5);
            _results.Data.Count.Should().Be(5);
            _results.Data.Items.Should().BeEquivalentTo(result);
        }
예제 #32
0
        private IDisposable UseEntireCollection()
        {
            //produce an observable when the underlying list changes, or when IsSelected changes
            var shared            = _source.Connect().Publish();
            var selectedChanged   = shared.WhenPropertyChanged(si => si.IsSelected).ToUnit().StartWith(Unit.Default);
            var collectionChanged = shared.ToCollection().CombineLatest(selectedChanged, (items, _) => items).Publish();

            return(new CompositeDisposable
                   (
                       collectionChanged.Select(items => items.Any(si => si.IsSelected)).Subscribe(result => HasSelection = result),
                       collectionChanged.Select(items =>
            {
                var count = items.Count(si => si.IsSelected);
                if (count == 0)
                {
                    return "Nothing Selected";
                }
                return count == 1 ? $"{count} item selected" : $"{count} items selected";
            })
                       .Subscribe(result => SelectedMessage = result),
                       shared.Connect(),
                       collectionChanged.Connect()
                   ));
        }
예제 #33
0
        public void ChainIsInvokedOnceForMultipleSubscribers()
        {
            int created   = 0;
            int disposals = 0;

            //Some expensive transform (or chain of operations)
            var longChain = _source.Connect()
                            .Transform(p => p)
                            .Do(_ => created++)
                            .Finally(() => disposals++)
                            .RefCount();

            var suscriber1 = longChain.Subscribe();
            var suscriber2 = longChain.Subscribe();
            var suscriber3 = longChain.Subscribe();

            _source.Add(new Person("Name", 10));
            suscriber1.Dispose();
            suscriber2.Dispose();
            suscriber3.Dispose();

            created.Should().Be(1);
            disposals.Should().Be(1);
        }
예제 #34
0
        public void RemoveWithoutIndex()
        {
            const string key    = "Adult1";
            var          person = new Person(key, 50);

            var results = _source.Connect().RemoveIndex().Transform(_transformFactory).AsAggregator();

            _source.Add(person);
            _source.Remove(person);

            results.Messages.Count.Should().Be(2, "Should be 2 updates");
            results.Messages[0].Adds.Should().Be(1, "Should be 1 addes");
            results.Messages[1].Removes.Should().Be(1, "Should be 1 removes");
            results.Data.Count.Should().Be(0, "Should be nothing cached");
        }
예제 #35
0
        public IObservable <IEnumerable <T> > Run()
        {
            var  emptyResult       = new List <T>();
            long orderItemWasAdded = -1;

            return(_sourceList.Connect().ObserveOn(_scheduler).Synchronize(_locker).Transform(t => new ExpirableItem <T>(t, _scheduler.Now.DateTime, Interlocked.Increment(ref orderItemWasAdded))).ToCollection().Select(
                       list =>
            {
                var numberToExpire = list.Count - _sizeLimit;
                if (numberToExpire < 0)
                {
                    return emptyResult;
                }

                return list.OrderBy(exp => exp.ExpireAt).ThenBy(exp => exp.Index).Take(numberToExpire).Select(item => item.Item).ToList();
            }).Where(items => items.Count != 0));
        }
        public void ChainFilters()
        {
            var filter2 = new BehaviorSubject <Func <Person, bool> >(person1 => person1.Age > 20);

            var stream = _source.Connect().Filter(_filter).Filter(filter2);

            var captureList = new List <int>();

            stream.Count().Subscribe(count => captureList.Add(count));

            var person = new Person("P", 30);

            _source.Add(person);

            person.Age = 10;
            _filter.OnNext(_filter.Value);

            captureList.Should().BeEquivalentTo(new[] { 1, 0 });
        }
예제 #37
0
        protected ComplexAuraTrigger()
        {
            var triggerList = new ObservableCollectionExtended <IAuraTrigger>();

            triggers
            .Connect()
            .DisposeMany()
            .Bind(triggerList)
            .Subscribe()
            .AddTo(Anchors);
            Triggers = triggerList;

            Observable.Merge(
                Triggers.ToObservableChangeSet().WhenPropertyChanged(x => x.IsActive).ToUnit(),
                Triggers.ToObservableChangeSet().ToUnit())
            .StartWithDefault()
            .Subscribe(() => IsActive = Triggers.All(x => x.IsActive))
            .AddTo(Anchors);
        }
예제 #38
0
 public void Initialise()
 {
     _source = new SourceList<Person>();
     _results = _source.Connect(p => p.Age > 20).AsAggregator();
 }
 public void Initialise()
 {
     _source = new SourceList<Person>();
     _filter = new FilterController<Person>(p => p.Age > 20);
     _results = _source.Connect().Filter(_filter, FilterPolicy.ClearAndReplace).AsAggregator();
 }
예제 #40
0
 public void MyTestInitialize()
 {
     _scheduler = new TestScheduler();
     _source = new SourceList<Person>();
     _results = _source.Connect().AsAggregator();
 }
		public void Initialise()
		{
			_source = new SourceList<Person>();
			_results = new ChangeSetAggregator<Person>(_source.Connect(p => p.Age > 20));
		}
예제 #42
0
        public void Initialise()
        {

           _source = new SourceList<Person>();
           _results = new ChangeSetAggregator<PersonWithGender>(_source.Connect().Transform(_transformFactory));
        }
예제 #43
0
 public void Initialise()
 {
     _source1 = new SourceList<int>();
     _source2 = new SourceList<int>();
     _results = _source1.Connect().Xor(_source2.Connect()).AsAggregator();
 }
예제 #44
0
 public void Initialise()
 {
     _source = new SourceList<DisposableObject>();
     _results = new ChangeSetAggregator<DisposableObject>(_source.Connect().DisposeMany());
 }
예제 #45
0
 public void Initialise()
 {
     _source = new SourceList<Person>();
     _controller = new PageController(new PageRequest(1,25));
     _results = _source.Connect().Page(_controller).AsAggregator();
 }
예제 #46
0
		public void SetUp()
		{
			_source = new SourceList<Person>();
			_results = _source.Connect().Sort(_comparer).AsAggregator();

		}
		public void Initialise()
		{
			_source = new SourceList<Person>();
			_results = _source.Connect().DistinctValues(p => p.Age).AsAggregator();
		}
예제 #48
0
 public void SetUp()
 {
     _source = new SourceList<int>();
     _results = _source.Connect().Reverse().AsAggregator();
 }