Inheritance: IMessageSender
Exemple #1
0
        static void Main(string[] args)
        {
            IMessageSender textMessageSender = new TextMessageSender();
            Message        textMessage       = new TextMessage(textMessageSender);

            textMessage.Send(); // output: TextMessageSender: Sending text message...

            IMessageSender emailMessageSender = new EmailMessageSender();
            Message        emailMessage       = new TextMessage(emailMessageSender);

            emailMessage.Send(); // output: EmailMessageSender: Sending email message...
        }
        static void Main()
        {
            IMessageSender text = new TextMessageSender();
            IMessageSender web  = new WebServiceMessageSender();

            Message message = new SystemMessage();

            message.Subject = "A Message";
            message.Body    = "Hi there, please accept this message!";

            message.MessageSender = text;
            message.Send();

            Console.WriteLine();

            message.MessageSender = web;
            message.Send();

            Console.Read();
        }