Пример #1
0
        /// <summary>
        /// Entry point into console application.
        /// </summary>
        static void Main()
        {
            // Create chatroom
            Chatroom chatroom = new Chatroom();

            // Create participants and register them
            Participant George = new Beatle("George");
            Participant Paul = new Beatle("Paul");
            Participant Ringo = new Beatle("Ringo");
            Participant John = new Beatle("John");
            Participant Yoko = new NonBeatle("Yoko");

            chatroom.Register(George);
            chatroom.Register(Paul);
            chatroom.Register(Ringo);
            chatroom.Register(John);
            chatroom.Register(Yoko);

            // Chatting participants
            Yoko.Send("John", "Hi John!");
            Paul.Send("Ringo", "All you need is love");
            Ringo.Send("George", "My sweet Lord");
            Paul.Send("John", "Can't buy me love");
            John.Send("Yoko", "My sweet love");

            // Wait for user
            Console.ReadKey();
        }
Пример #2
0
        /// <summary>
        /// Entry point into console application.
        /// </summary>
        static void Main()
        {
            // Create chatroom
            Chatroom chatroom = new Chatroom();

            // Create participants and register them
            Participant George = new Beatle("George");
            Participant Paul   = new Beatle("Paul");
            Participant Ringo  = new Beatle("Ringo");
            Participant John   = new Beatle("John");
            Participant Yoko   = new NonBeatle("Yoko");

            chatroom.Register(George);
            chatroom.Register(Paul);
            chatroom.Register(Ringo);
            chatroom.Register(John);
            chatroom.Register(Yoko);

            // Chatting participants
            Yoko.Send("John", "Hi John!");
            Paul.Send("Ringo", "All you need is love");
            Ringo.Send("George", "My sweet Lord");
            Paul.Send("John", "Can't buy me love");
            John.Send("Yoko", "My sweet love");

            // Wait for user
            Console.ReadKey();
        }
Пример #3
0
        static void Main(string[] args)
        {
            // Crear sala de chat

            Chatroom chatroom = new Chatroom();



            // Crea participantes y regístralos.

            Participant George = new Beatle("George");

            Participant Paul = new Beatle("Paul");

            Participant Ringo = new Beatle("Ringo");

            Participant John = new Beatle("John");

            Participant Yoko = new NonBeatle("Yoko");



            chatroom.Register(George);

            chatroom.Register(Paul);

            chatroom.Register(Ringo);

            chatroom.Register(John);

            chatroom.Register(Yoko);



            // participantes en el chat

            Yoko.Send("John", "Hi John!");

            Paul.Send("Ringo", "All you need is love");

            Ringo.Send("George", "My sweet Lord");

            Paul.Send("John", "Can't buy me love");

            John.Send("Yoko", "My sweet love");



            // Esperando a usar

            Console.ReadKey();
        }
Пример #4
0
        static void Main()
        {
            /*
             * Structural Mediator
             */
            StructuralConcreteMediator m = new StructuralConcreteMediator();

            StructuralConcreteColleague1 c1 = new StructuralConcreteColleague1(m);
            StructuralConcreteColleague2 c2 = new StructuralConcreteColleague2(m);

            m.Colleague1 = c1;
            m.Colleague2 = c2;

            c1.Send("How are you?");
            c2.Send("Find, thanks");

            /*
             *  Real-World Mediator
             */

            Chatroom chatroom = new Chatroom();

            Participant george = new Beatle("George");
            Participant paul   = new Beatle("Paul");
            Participant ringo  = new Beatle("Ringo");
            Participant john   = new Beatle("John");
            Participant yoko   = new NonBeatle("Yoko");

            List <Participant> participantList = new List <Participant>()
            {
                george, paul, ringo, john, yoko
            };

            foreach (var beatle in participantList)
            {
                chatroom.Register(beatle);
            }

            // Chatting participants
            yoko.Send("John", "Hi John!");
            paul.Send("Ringo", "All you need is love");
            ringo.Send("George", "My sweet Lord");
            paul.Send("John", "Can't buy me love");
            john.Send("Yoko", "My sweet love");
        }
Пример #5
0
        static void Main(string[] args)
        {
            Chatroom chatroom = new Chatroom();

            Participant george = new Beatle("George");
            Participant john   = new Beatle("John");
            Participant paul   = new Beatle("Paul");
            Participant ringo  = new Beatle("Ringo");
            Participant yoko   = new NonBeatle("Yoko");

            chatroom.Register(george);
            chatroom.Register(john);
            chatroom.Register(paul);
            chatroom.Register(ringo);
            chatroom.Register(yoko);

            yoko.Send("John", "Hi John!");
            paul.Send("Ringo", "All you need is love");
            ringo.Send("George", "My sweet Lord");
            paul.Send("John", "Can't buy me love");
            john.Send("Yoko", "My sweet love");

            Console.ReadKey();
        }