示例#1
0
        static void Main(string[] args)
        {
            IMessageSender text = new TextSender();
            IMessageSender web  = new WebServiceSender();

            Message message = new SystemMessage();

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

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

            message.MessageSender = web;
            message.Send();
        }
        /// <summary>
        /// Bridge Design Pattern Demo
        /// </summary>
        static void Main(string[] args)
        {
            IMessageSender text = new TextSender();
            IMessageSender web  = new WebServiceSender();

            Message message = new SystemMessage
            {
                Subject = "A Message",
                Body    = "Hi there, Please accept this message."
            };

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

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

            Console.ReadKey();
        }
        static void Main(string[] args)
        {
            //create instances of a text sender and a web sender:
            IMessageSender text = new TextSender();
            IMessageSender web  = new WebServiceSender();

            //create a message and put stuff in it:
            Message message = new SystemMessage();

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

            //send it via text:
            //first assign the message to the text instance of a message sender.
            message.MessageSender = text;
            message.Send();

            //send it via web:
            //first assign the message to the web instance of a message sender.
            message.MessageSender = web;
            message.Send();

            Console.ReadKey();
        }