static void Main(string[] args) { NewsPublisher newsPublisher = new NewsPublisher(); //NewsSubscriber newsSubscriber1 = new NewsSubscriber(1,newsPublisher); //NewsSubscriber newsSubscriber2 = new NewsSubscriber(2,newsPublisher); NewsSubscriber newsSubscriber1 = new NewsSubscriber(1); newsPublisher.NewsPublishedEvent += newsSubscriber1.Replay; NewsSubscriber newsSubscriber2 = new NewsSubscriber(2); newsPublisher.NewsPublishedEvent += newsSubscriber2.Replay; newsPublisher.PublishNews(); Console.ReadLine(); }
public NewsSubscriber(int number, NewsPublisher newsPublisher) { _number = number; _newsPublisher = newsPublisher; _newsPublisher.NewsPublishedEvent += Replay; }