コード例 #1
0
ファイル: MediatorPattern.cs プロジェクト: prnawa/DPSharp
        public void TestMethod1()
        {
            var mediator   = new ConcreteMediator();
            var colleague1 = new ConcreteColleague(mediator);
            var colleague2 = new ConcreteColleague(mediator);

            mediator.AddColleague(colleague1);
            mediator.AddColleague(colleague2);

            colleague1.Send("form C1");
            colleague2.Send("from C2");
        }
コード例 #2
0
ファイル: TEST.cs プロジェクト: ibeae/ThinkAway.net
        public void MediatorTest()
        {
            ConcreteMediator concreteMediator = new ConcreteMediator();

            Action <Intent> action = x => _logger.Debug("mediator", x.EventMessage);

            concreteMediator.AddColleague("testA", new ColleagueDelegate(action));
            concreteMediator.AddColleague("testB", new ColleagueDelegate(action));

            concreteMediator.Trigger("testA", "test");

            concreteMediator.Execute(new Intent("aaaaaaaaaaa"));
        }
コード例 #3
0
ファイル: MediatorPatternTest.cs プロジェクト: alexcxd/Text
        public void MediatorPatternCodeTest()
        {
            ConcreteMediator mediator = new ConcreteMediator();

            ConcreteColleagueA colleagueA = new ConcreteColleagueA(1, mediator);

            ConcreteColleagueB colleagueB = new ConcreteColleagueB(2, mediator);

            mediator.AddColleague(colleagueA);
            mediator.AddColleague(colleagueB);

            colleagueA.Send("你好", colleagueB);
            colleagueB.Send("hi", colleagueA);
        }
コード例 #4
0
    private void Start()
    {
        ConcreteMediator m = new ConcreteMediator();

        ConcreteColleague1 c1 = new ConcreteColleague1(m);
        ConcreteColleague2 c2 = new ConcreteColleague2(m);
        ConcreteColleague  c3 = new ConcreteColleague(m);
        ConcreteColleague  c4 = new ConcreteColleague(m);
        ConcreteColleague  c5 = new ConcreteColleague(m);
        ConcreteColleague  c6 = new ConcreteColleague(m);
        ConcreteColleague  c7 = new ConcreteColleague(m);

        //m.Colleague1 = c1;
        //m.Colleague2 = c2;
        m.AddColleague(c1);
        m.AddColleague(c2);
        m.AddColleague(c3);
        m.AddColleague(c4);
        m.AddColleague(c5);
        m.AddColleague(c6);
        m.AddColleague(c7);

        c1.Send("How are you?");
        c2.Send("Fine, thanks");
    }