Beispiel #1
0
    public static void UnitTest()
    {
        ConcreteSubject   theSubject   = new ConcreteSubject();
        ConcreteObserver1 theObserver1 = new ConcreteObserver1(theSubject);

        theSubject.Attach(theObserver1);

        theSubject.Attach(new ConcreteObserver2(theSubject));

        theSubject.SetState("Subject Stat 1");

        // Simulate Update Call in GameLoop
        theSubject.Notify();

        theObserver1.ShowState();
    }
Beispiel #2
0
    // Update is called once per frame
    void UnitTest()
    {
        // 主题
        ConcreteSubject theSubject = new ConcreteSubject();

        // 加入观察者
        ConcreteObserver1 theObserver1 = new ConcreteObserver1(theSubject);

        theSubject.Attach(theObserver1);
        theSubject.Attach(new ConcreteObserver2(theSubject));

        // 设定Subject
        theSubject.SetState("Subject状态1");

        // 显示状态
        theObserver1.ShowState();
    }
Beispiel #3
0
    // Update is called once per frame
    void UnitTest()
    {
        // 主題
        ConcreteSubject theSubject = new ConcreteSubject();

        // 加入觀察者
        ConcreteObserver1 theObserver1 = new ConcreteObserver1(theSubject);

        theSubject.Attach(theObserver1);
        theSubject.Attach(new ConcreteObserver2(theSubject));

        // 設定Subject
        theSubject.SetState("Subject狀態1");

        // 顯示狀態
        theObserver1.ShowState();
    }