Пример #1
0
        /// <summary>
        /// Delivers the magazine to all subscribed subscribers.
        /// </summary>
        /// <param name="magazine"></param>
        public void Deliver(Magazine magazine)
        {
            if (!_subscribers.ContainsKey(magazine.Title))
            {
                Console.WriteLine($"There are no subscribers for {magazine.Title}.");
            }

            var count = 0;

            foreach (var subscriber in _subscribers[magazine.Title])
            {
                subscriber.Receive(magazine);
                count++;
            }

            Console.WriteLine($"Delivered {magazine.Title} {magazine.Edition} to {count} subscribers.");
        }
Пример #2
0
        public void Publish(Magazine magazine)
        {
            Console.WriteLine($"{Name} published {magazine.Title} {magazine.Edition}.");

            _agent.Deliver(magazine);
        }
Пример #3
0
 public void Receive(Magazine magazine)
 {
     Console.WriteLine($"{Name} received {magazine.Title} {magazine.Edition}.");
 }