예제 #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();
    }
예제 #2
0
    // Start is called before the first frame update
    void Start()
    {
        ColleagueMediator mediator = new ColleagueMediator();

        ConcreateColleague1 colleague1 = new ConcreateColleague1(mediator);
        ConcreateColleague2 colleague2 = new ConcreateColleague2(mediator);

        mediator.Colleague1 = colleague1;
        mediator.Colleague2 = colleague2;

        colleague1.SendMsg("1");
        colleague2.SendMsg("2");
    }
    void UnitTest()
    {
        ConcreateMadiator m_Mediator = new ConcreateMadiator();                 //new 中介者

        ConcreateColleague1 m_Colleague1 = new ConcreateColleague1(m_Mediator); //new C1
        ConcreateColleague2 m_Colleague2 = new ConcreateColleague2(m_Mediator); //new C2

        m_Mediator.SetColleague1(m_Colleague1);                                 //中介者设置
        m_Mediator.SetColleague2(m_Colleague2);                                 //中介者设置

        m_Colleague1.Action();                                                  //执行
        m_Colleague2.Action();                                                  //执行
    }
예제 #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();
    }
예제 #5
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();
    }
예제 #6
0
 public void SetColleageu1(ConcreateColleague1 theColleague)
 {
     m_Colleague1 = theColleague;
 }
 public void SetColleague1(ConcreateColleague1 theColleague1)
 {
     m_Colleague1 = theColleague1;
 }