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); } }
public LoginForm(IUdpSender udpSender, ISubject <LoginResponse> loginSubject, IStorage storage, IServiceProvider provider) { _udpSender = udpSender; _storage = storage; _provider = provider; loginSubject.Attach(this); InitializeComponent(); }
//释放 //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; } }
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); }
public CurrentsScreen(ISubject subject) { InitializeComponent(); subject.Attach(this); }
/// <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); }
public TVDisplay(ISubject s) { subject = s; s.Attach(this); }
public PortfolioDisplay(ISubject <Portfolio> subject) { _portfolieSubject = subject; _portfolieSubject.Attach(this); }
public MinimumScreen(ISubject subject) { InitializeComponent(); subject.Attach(this); }
public void Observe(ISubject s) { _subject = s; _subject.Attach(this); }
public void AddSubject(ISubject subject) { Stocks.Add((Stock)subject); subject.Attach(this); }
public Teletubbie(string name, ISubject sub) { this.name = name; sub.Attach(this); }
public void DetachFrom(ISubject subject) { subject.Attach(this); }
public ObserverB(ISubject subject) { subject.Attach(this); }
public Portfolio(ISubject <Stock> subject) { StockSubject = subject; StockSubject.Attach(this); stocksInPortfolio = new List <Stock>(); }
public void AttachTo(ISubject subject) { subject.Attach(this); }
public Observer(ILoggerFactory loggerFactory, ISubject subject) { _logger = loggerFactory.CreateLogger <Observer>(); subject.Attach(this); }