Exemple #1
0
        private static void Main(string[] args)
        {
            var mailManager = new MailManager();

            mailManager.NewMail += MailManagerNewMail;

            var printer = new Printer(mailManager);

            #region
            var sms = new SMS();
            mailManager.NewMail += sms.MmNewMail;


            Console.Write("Введите ваше имя: ");
            var sender = Console.ReadLine();

            Console.Write("С кем вы хотите связаться? Введите имя: ");
            var target = Console.ReadLine();

            Console.WriteLine("Введите текст сообщения:");
            var message = Console.ReadLine();

            mailManager.SimulateNewMail(sender, target, message);
            Console.ReadLine();
            #endregion

            #region
            var typeWithLotsOfEvents = new TypeWithLotsEvents();
            typeWithLotsOfEvents.Foo += TypeWithLotsOfEvents_Foo;
            typeWithLotsOfEvents.SimulateFoo();
            Console.ReadLine();
            #endregion
        }
Exemple #2
0
 public Printer(MailManager mailManager)
 {
     mailManager.NewMail += OnNewMailEvent;
     //mailManager.add_NewMail(new EventHandler<NewMailEventArgs>(OnNewMailEvent));
 }
Exemple #3
0
 public void Unregister(MailManager mailManager)
 {
     mailManager.NewMail -= OnNewMailEvent;
 }