Exemplo n.º 1
0
        public void SetUp()
        {
            groupedValues = new StatsSubject <Tuple <int, IObservable <int> > >();
            stats         = new StatsObserver <string>();

            left  = new StatsSubject <int>();
            right = new StatsSubject <int>();

            leftWindows  = new List <StatsSubject <Unit> >();
            rightWindows = new List <StatsSubject <Unit> >();

            leftValueAction = rightValueAction = () => { };

            combineAction = (l, r) => {};

            subscription = new CompositeDisposable();

            subscription.Add(left.GroupJoin(right,
                                            leftVal =>
            {
                leftValueAction();
                var leftWindow = new StatsSubject <Unit>();
                leftWindows.Add(leftWindow);
                return(leftWindow);
            },
                                            rightVal =>
            {
                rightValueAction();
                var rightWindow = new StatsSubject <Unit>();
                rightWindows.Add(rightWindow);
                return(rightWindow);
            },
                                            (l, r) =>
            {
                combineAction(l, r);

                return(new Tuple <int, IObservable <int> >(l, r));
            })
                             .Subscribe(groupedValues));

            subscription.Add(groupedValues
                             .SelectMany(input => input.Item2.Select(r => new Tuple <int, int>(input.Item1, r)))
                             .Select(t => String.Format("{0},{1}", t.Item1, t.Item2))
                             .Subscribe(stats));
        }
Exemplo n.º 2
0
        public void SetUp()
        {
            groupedValues = new StatsSubject<Tuple<int, IObservable<int>>>();
            stats = new StatsObserver<string>();

            left = new StatsSubject<int>();
            right = new StatsSubject<int>();

            leftWindows = new List<StatsSubject<Unit>>();
            rightWindows = new List<StatsSubject<Unit>>();

            leftValueAction = rightValueAction = () => { };

            combineAction = (l, r) => {};

            subscription = new CompositeDisposable();

            subscription.Add(left.GroupJoin(right,
                leftVal =>
                {
                    leftValueAction();
                    var leftWindow = new StatsSubject<Unit>();
                    leftWindows.Add(leftWindow);
                    return leftWindow;
                },
                rightVal =>
                {
                    rightValueAction();
                    var rightWindow = new StatsSubject<Unit>();
                    rightWindows.Add(rightWindow);
                    return rightWindow;
                },
                (l, r) =>
                {
                    combineAction(l,r);

                    return new Tuple<int, IObservable<int>>(l, r);
                })
                .Subscribe(groupedValues));

            subscription.Add(groupedValues
                .SelectMany(input => input.Item2.Select(r => new Tuple<int, int>(input.Item1, r)))
                .Select(t => String.Format("{0},{1}", t.Item1, t.Item2))
                .Subscribe(stats));
        }