예제 #1
0
 private void btnAddObserver_Click(object sender, EventArgs e)
 {
     if (this.cbxObserverType.Text == "客户")
     {
         IObserver observer = new Customer("客户" + this.txtName.Text, this.txtLog);
         lbxObserver.Items.Add(observer);
         Subject.Attach(observer);
     }
     else if (this.cbxObserverType.Text == "采购")
     {
         IObserver observer = new Buyer("采购" + this.txtName.Text, this.txtLog);
         lbxObserver.Items.Add(observer);
         Subject.Attach(observer);
     }
 }
예제 #2
0
        public LoginForm(IUdpSender udpSender, ISubject <LoginResponse> loginSubject, IStorage storage, IServiceProvider provider)
        {
            _udpSender = udpSender;
            _storage   = storage;
            _provider  = provider;

            loginSubject.Attach(this);

            InitializeComponent();
        }
예제 #3
0
    //释放
    //public override void Release()
    //{
    //    gameevents.Clear();
    //}
    public void RegisterObserver(Enum_GameEvent gameEvent, IObserver observer)
    {
        ISubject subject = GetGameEvent(gameEvent);

        if (subject != null)
        {
            subject.Attach(observer);
            observer.Subject = subject;
        }
    }
예제 #4
0
        private void MainFrom_Load(object sender, EventArgs e)
        {
            Restaurant restaurantSubject = new Restaurant();

            restaurantSubject.Menus = @"糖醋排骨 50
                                        油焖大虾 20
                                        糖醋里脊 10
                                        土豆丝   15";
            this.txtMenu.Text       = restaurantSubject.Menus;
            Subject = restaurantSubject;
            Customer customer  = new Customer("客户小张", this.txtLog);
            Customer customer2 = new Customer("客户小李", this.txtLog);
            Buyer    buyer     = new Buyer("采购小王", this.txtLog);

            lbxObserver.Items.Add(customer);
            lbxObserver.Items.Add(customer2);
            lbxObserver.Items.Add(buyer);
            Subject.Attach(customer);
            Subject.Attach(customer2);
            Subject.Attach(buyer);
        }
        public static void publishTopic(string topic, ISubject subject)
        {
            subjectMap.Add(topic, subject);

            //go through waitlist and see if theres an observer waiting for the topic
            foreach (TopicObserver topicObserver in observerWaitList)
            {
                if (topicObserver.topic == topic)
                {
                    subject.Attach(topicObserver.observer);
                }
            }
        }
        public AveragesScreen(ISubject subject)
        {
            InitializeComponent();

            subject.Attach(this);
        }
예제 #7
0
 public CurrentsScreen(ISubject subject)
 {
     InitializeComponent();
     subject.Attach(this);
 }
예제 #8
0
파일: Refer.cs 프로젝트: vinhphu3000/mg01
        /// <summary>
        /// 监听析构,(暂时是retain用到)
        /// </summary>
        /// <param name="refer_"></param>
        /// <param name="callback_"></param>
        static public void AttachDispose(object refer_, CALLBACK_1 callback_)
        {
            string referId = Format(refer_);

            __subDispose.Attach(referId, callback_, null);
        }
예제 #9
0
 public TVDisplay(ISubject s)
 {
     subject = s;
     s.Attach(this);
 }
예제 #10
0
 public PortfolioDisplay(ISubject <Portfolio> subject)
 {
     _portfolieSubject = subject;
     _portfolieSubject.Attach(this);
 }
예제 #11
0
 public MinimumScreen(ISubject subject)
 {
     InitializeComponent();
     subject.Attach(this);
 }
예제 #12
0
 public void Observe(ISubject s)
 {
     _subject = s;
     _subject.Attach(this);
 }
예제 #13
0
파일: Portfolio.cs 프로젝트: Tueaj/SkoleGIT
 public void AddSubject(ISubject subject)
 {
     Stocks.Add((Stock)subject);
     subject.Attach(this);
 }
예제 #14
0
 public Teletubbie(string name, ISubject sub)
 {
     this.name = name;
     sub.Attach(this);
 }
예제 #15
0
 public void DetachFrom(ISubject subject)
 {
     subject.Attach(this);
 }
예제 #16
0
 public ObserverB(ISubject subject)
 {
     subject.Attach(this);
 }
예제 #17
0
 public Portfolio(ISubject <Stock> subject)
 {
     StockSubject = subject;
     StockSubject.Attach(this);
     stocksInPortfolio = new List <Stock>();
 }
예제 #18
0
 public void AttachTo(ISubject subject)
 {
     subject.Attach(this);
 }
예제 #19
0
 public Observer(ILoggerFactory loggerFactory, ISubject subject)
 {
     _logger = loggerFactory.CreateLogger <Observer>();
     subject.Attach(this);
 }