예제 #1
0
        public void SendWhatsAppMessage(string[] names, string text)
        {
            IMessageChannel messageChannel = new WhatsAppChannel();

            foreach (Contact contact in this.persons)
            {
                foreach (string name in names)
                {
                    if (contact.Name.Equals(name))
                    {
                        Message message = new WhatsAppMessage(this.Owner.Phone, contact.Phone, text);
                        messageChannel.Send(message);
                    }
                }
            }
        }
예제 #2
0
        static void Main(string[] args)
        {
            Contact   owner     = new Contact("Federico");
            Phonebook phonebook = new Phonebook(owner);
            Contact   contact1  = phonebook.AddContact("Patricio");

            contact1.Phone   = "+59891409412";
            contact1.Twitter = "73234797";
            Contact contact2 = phonebook.AddContact("Valentina");

            contact2.Phone   = "+59894877936";
            contact2.Twitter = "1111111111";
            string[]        names    = { "Patricio", "Valentina" };
            List <Contact>  contacts = phonebook.Search(names);
            IMessageChannel channel  = new TwitterChannel();

            phonebook.SendTo(contacts, "Message was sent!", channel);
            channel = new WhatsAppChannel();
            phonebook.SendTo(contacts, "Message was sent!", channel);
        }