Ejemplo n.º 1
0
 public void CountMessages(List <string> peopleList)
 {
     foreach (string person in peopleList)
     {
         // implement your logic to send name of people after apearing 3*n times
         if (!dic.ContainsKey(person))
         {
             dic.Add(person, 1);
         }
         else
         {
             foreach (string name in dic.Keys)
             {
                 if (person == name)
                 {
                     dic[name] += 1;
                     if (dic[name] % 3 == 0)
                     {
                         PersonEventArgs p = new PersonEventArgs();
                         p.Name = person;
                         OnContactNotify(p); // Notify subscribers
                     }
                     break;
                 }
             }
         }
     }
 }
Ejemplo n.º 2
0
        protected virtual void OnContactNotify(PersonEventArgs e)
        {
            EventHandler <PersonEventArgs> sender = ContactNotify;

            if (sender != null)
            {
                sender(this, e);
            }
        }
Ejemplo n.º 3
0
 public static void Send(object source, PersonEventArgs e)
 {
     Console.WriteLine(e.Name);
 }