Example #1
0
        static void Main(string[] args)
        {
            WorldCup2014Table w  = new WorldCup2014Table();
            GroupManager      gm = new GroupManager(w);

            var roundOf16Sub = gm.AdvancedToNext
                               .Subscribe(RoundOf16Handler);

            var scoreSub = gm.MatchFromGroup
                           .Buffer(2)
                           .Select(x => Tuple.Create(gm, x.First().Item1))
                           .Subscribe(DisplayScore);

            //w.Matches[0].FinalScore(3, 1);
            //w.Matches[1].FinalScore(1, 0);
            //w.Matches[2].FinalScore(0, 0);
            //w.Matches[3].FinalScore(0, 4);
            //w.Matches[4].FinalScore(1, 3);
            //w.Matches[5].FinalScore(1, 4);

            //w.Matches[6].FinalScore(1, 5);
            //w.Matches[7].FinalScore(3, 1);
            //w.Matches[8].FinalScore(2, 3);
            //w.Matches[9].FinalScore(0, 2);
            //w.Matches[10].FinalScore(0, 3);
            //w.Matches[11].FinalScore(2, 0);

            //imagine this as a live and timed stream
            w.Matches[0].FinalScore(3, 1);
            w.Matches[1].FinalScore(1, 0);
            w.Matches[6].FinalScore(1, 5);
            w.Matches[7].FinalScore(3, 1);
            w.Matches[2].FinalScore(0, 0);
            w.Matches[3].FinalScore(0, 4);
            w.Matches[8].FinalScore(2, 3);
            w.Matches[9].FinalScore(0, 2);
            w.Matches[10].FinalScore(0, 3);
            w.Matches[11].FinalScore(2, 0);
            w.Matches[4].FinalScore(1, 3);
            w.Matches[5].FinalScore(1, 4);
            //...

            scoreSub.Dispose();
            roundOf16Sub.Dispose();

            Console.ReadLine();
        }
Example #2
0
        public GroupManager(WorldCup2014Table table)
        {
            if (null == table)
            {
                throw new ArgumentNullException("table");
            }

            Table = table;

            Points = new PointInfo[48];
            for (int i = 0; i < 48; ++i)
            {
                Points[i] = new PointInfo((Team)i);
            }

            AdvancedToNextSubject = new Subject <Tuple <WorldCup2014Table.Group, Tuple <Team, Team> > >();

            MatchFromGroupSubject = new Subject <Tuple <WorldCup2014Table.Group, Match> >();

            foreach (var match in Table.Groups)
            {
                match.Result.Subscribe(this);
            }
        }