Beispiel #1
0
    //
    void UnitTest()
    {
        ConcreteMediator pMediator = new ConcreteMediator();

        ConcreateColleague1 pColleague1 = new ConcreateColleague1(pMediator);
        ConcreateColleague2 pColleague2 = new ConcreateColleague2(pMediator);

        pMediator.SetColleageu1(pColleague1);
        pMediator.SetColleageu2(pColleague2);

        pColleague1.Action();
        pColleague2.Action();
    }
    void Start()
    {
        ConcreteMediator mediator = new ConcreteMediator();

        ConcreateGroup0 group0 = new ConcreateGroup0(mediator);
        ConcreateGroup1 group1 = new ConcreateGroup1(mediator);

        mediator.SetColleageu1(group0);
        mediator.SetColleageu2(group1);

        group0.Action();
        group1.Action();
    }
Beispiel #3
0
    //
    void UnitTest()
    {
        // 产生仲介者
        ConcreteMediator pMediator = new ConcreteMediator();

        // 产生两个Colleague
        ConcreateColleague1 pColleague1 = new ConcreateColleague1(pMediator);
        ConcreateColleague2 pColleague2 = new ConcreateColleague2(pMediator);

        // 设定给仲介者
        pMediator.SetColleageu1(pColleague1);
        pMediator.SetColleageu2(pColleague2);

        // 执行
        pColleague1.Action();
        pColleague2.Action();
    }
Beispiel #4
0
    //
    void UnitTest()
    {
        // 產生仲介者
        ConcreteMediator pMediator = new ConcreteMediator();

        // 產生兩個Colleague
        ConcreateColleague1 pColleague1 = new ConcreateColleague1(pMediator);
        ConcreateColleague2 pColleague2 = new ConcreateColleague2(pMediator);

        // 設定給仲介者
        pMediator.SetColleageu1(pColleague1);
        pMediator.SetColleageu2(pColleague2);

        // 執行
        pColleague1.Action();
        pColleague2.Action();
    }