Ejemplo n.º 1
0
 /// <summary>
 /// raise the event
 /// </summary>
 /// <param name="mailArrivedArgs"></param>
 protected virtual void OnMailArrived(MailArrivedEventArgs mailArrivedArgs)
 {
     if (MailArrived != null)
     {
         MailArrived(this, mailArrivedArgs);
     }
 }
Ejemplo n.º 2
0
        private static void Mgr_MailArrived(object sender, MailArrivedEventArgs e)
        {
            var title = !string.IsNullOrEmpty(e.Title) ? e.Title : string.Empty;
            var body  = !string.IsNullOrEmpty(e.Body) ? e.Body : string.Empty;

            Console.WriteLine($"Message title: {title}, Message body: {body}");
        }
Ejemplo n.º 3
0
 protected virtual void OnMailArrived(MailArrivedEventArgs arg)
 {
     if (MailArrived != null)
     {
         MailArrived(this, arg);
     }
 }
        protected virtual void OnMailArrived(MailArrivedEventArgs argument)
        {
            EventHandler <MailArrivedEventArgs> mailArrived = MailArrived;

            if (mailArrived != null)
            {
                mailArrived(this, argument);
            }
        }
Ejemplo n.º 5
0
        virtual protected void OnMailArrived(MailArrivedEventArgs args)
        {
            EventHandler <MailArrivedEventArgs> handler = MailArrived;

            if (MailArrived != null)
            {
                MailArrived(this, args);
            }
        }
Ejemplo n.º 6
0
        static void Main(string[] args)
        {
            MailManager manager  = new MailManager();
            var         autoArgs = new MailArrivedEventArgs("this is a test", "test");

            manager.MailArrived += MailArrivedHandler;
            manager.SimulateMailArrived(autoArgs);
            Timer startTimer = new Timer(MailCallback, autoArgs, 1000, 1000);

            Console.ReadLine();
        }
Ejemplo n.º 7
0
        public static void Main(string[] args)
        {
            _manager = new MailManager();
            var mailArgs = new MailArrivedEventArgs("Testing Mail Arrived Event", "TESTED");

            _manager.MailArrived += MailArrivedHandler;
            _manager.SimulateMailArrived(mailArgs);

            Timer timer = new Timer(Callback, mailArgs, 1000, 1000);

            Console.ReadLine();
        }
 public void SimulateMailArrived()
 {
     if (_timer != null)
     {
         MailArrivedEventArgs argument = new MailArrivedEventArgs("Test title", "Test body");
         OnMailArrived(argument);
     }
     else
     {
         _timer = new Timer(this._callBack, this, 0, 1000);
     }
 }
Ejemplo n.º 9
0
 protected virtual void OnMailArrived(MailArrivedEventArgs e)
 {
     //You are missing a step.
     //var handler = MailArrived;
     //if (null != handler)
     //{
     //    handler(this, args);
     //}
     //Or use C# 6 feature: MailArrived?.Invoke(this, args);
     if (MailArrived != null)
     {
         MailArrived(this, e);
     }
 }
Ejemplo n.º 10
0
        public static void Main(string[] args)
        {
            MailManager          manager     = new MailManager();
            MailArrivedEventArgs mail        = new MailArrivedEventArgs("Nelly", "you got a new messege");
            MailArrivedEventArgs anotherMail = new MailArrivedEventArgs("Dror", "Mail");

            manager.MailArrived += GotMail;
            manager.SimulateMailArrived(new object());
            manager.MailSent(mail);
            manager.MailSent(anotherMail);

            TimerCallback timeCall = manager.SimulateMailArrived;

            System.Threading.Timer timer = new System.Threading.Timer(timeCall, null, 0, 1000);
            System.Threading.Thread.Sleep(10000);
        }
Ejemplo n.º 11
0
        } /*** end main ***********************************/

        // 8.In the handler, output the title and body to the console.
        static void MailArrivedHandler(Object sender, MailArrivedEventArgs e)
        {
            Console.WriteLine("Title: {0}", e.Title);
            Console.WriteLine("Body: {0}", e.Body);
            Console.WriteLine();
        } /**************************************/
Ejemplo n.º 12
0
        /// <summary>
        /// calls OnMailArrived with some dummy data
        /// </summary>
        public void SimulateMailArrived()
        {
            var mailArrivedArgs = new MailArrivedEventArgs("A message to the Checker", "Dear Checker, I wish to get a good remaks in this lab please.");

            OnMailArrived(mailArrivedArgs);
        }
Ejemplo n.º 13
0
 public void SimulateMailArrived(MailArrivedEventArgs e)
 {
     OnMailArrived(e);
 }
Ejemplo n.º 14
0
 private static void Manager_MailArrived(object sender, MailArrivedEventArgs e)
 {
     Console.WriteLine("Title: " + e?.Title);
     Console.WriteLine("Body: " + e?.Body);
 }
Ejemplo n.º 15
0
 static void Mm_MailArrived(object sender, MailArrivedEventArgs e)
 {
     Console.WriteLine("Title: " + e.Title);
     Console.WriteLine("Body: " + e.Body);
 }
Ejemplo n.º 16
0
 public static void MailManager_MailArrived(object sender, MailArrivedEventArgs e)
 {
     Console.WriteLine(e.Title);
     Console.WriteLine(e.Body);
 }
Ejemplo n.º 17
0
 static void manager_MailArrived(object sender, MailArrivedEventArgs e)
 {
     Console.WriteLine($"{e.Title} : {e.Body}");
 }
Ejemplo n.º 18
0
 public static void MailArrivedHandler(object sender, MailArrivedEventArgs args)
 {
     Console.WriteLine(args.Title);
     Console.WriteLine("\n" + args.Body);
 }
Ejemplo n.º 19
0
 public void SimulateMailArrived(MailArrivedEventArgs args)
 {
     Console.WriteLine("Sending e-mail...");
     OnMailArrived(args);
 }
 public void MailArrivedEvent(object sender, MailArrivedEventArgs e)
 {
     Console.WriteLine($"Title is:\n{e.Title}\nBody is:\n{e.Body}");
 }
Ejemplo n.º 21
0
 protected virtual void OnMailArrived(MailArrivedEventArgs e)
 {
     //Awesome.
     MailArrived?.Invoke(this, e);
 }
Ejemplo n.º 22
0
        public void SimulateMailArrived()
        {
            MailArrivedEventArgs args = new MailArrivedEventArgs("Mail title", "content of mail");

            OnMailArrived(args);
        }
Ejemplo n.º 23
0
 protected virtual void OnMailArrived(MailArrivedEventArgs e)
 {
     MailArrived(this, e);
 }
Ejemplo n.º 24
0
        public void SimulateMailArrived()
        {
            MailArrivedEventArgs args = new MailArrivedEventArgs("junk mail", "junk junk junk junk");

            OnMailArrived(args);
        }
Ejemplo n.º 25
0
 protected virtual void OnMailArrived(MailArrivedEventArgs args)
 {
     MailArrived?.Invoke(this, args);
 }
Ejemplo n.º 26
0
 public static void GotMail(object sender, MailArrivedEventArgs e)
 {
     Console.WriteLine(e.Title);
     Console.WriteLine(e.Body);
     System.Threading.Thread.Sleep(3000);
 }
Ejemplo n.º 27
0
 public void SimulateMailArrived(object obj)
 {
     obj = new MailArrivedEventArgs("dummy title", "dummy body");
     OnMailArrived(obj as MailArrivedEventArgs);
 }
Ejemplo n.º 28
0
        public void SimulateMailArrived()
        {
            MailArrivedEventArgs mail = new MailArrivedEventArgs("simulate mail - title", "simulate mail - body");

            OnMailArrived(mail);
        }
Ejemplo n.º 29
0
 public static void OnNewMail(object sender, MailArrivedEventArgs e)
 {
     Console.WriteLine("Mail arrived at {2}: {0} Contents: {1}",
                       e.Title, e.Body, DateTime.Now.ToLongTimeString());
 }
Ejemplo n.º 30
0
 public void MailSent(MailArrivedEventArgs mail)
 {
     OnMailArrived(mail);
 }