static void Main(string[] args)
        {
            /*En nuestro Main(), podemos usar nuestro Mediador
             * recién escrito para simular una conversación de chat
             * entre las dos cafeterías.
             * Suponga que una de las barras de bocadillos se ha quedado
             * sin palomitas de maíz y necesita saber si la otra tiene
             * más que no están usando
             *
             */
            ConcessionsMediator mediator = new ConcessionsMediator();

            NorthConcessionStand leftKitchen  = new NorthConcessionStand(mediator);
            SouthConcessionStand rightKitchen = new SouthConcessionStand(mediator);

            mediator.NorthConcessions = leftKitchen;
            mediator.SouthConcessions = rightKitchen;

            leftKitchen.Send("¿Puedes envíar palomitas de maíz");
            rightKitchen.Send("Claro, Kenny está en camino..");

            rightKitchen.Send("¿Tienes perros calientes extra ? Hemos tenido prisa por ellos por aquí.");
            leftKitchen.Send("Solo un par, enviaremos a Kenny con ellos.");


            Console.ReadKey();
        }
Example #2
0
        /// <summary>
        /// The Mediator pattern allows us to create an object which defines how other objects interact or
        /// communicate with each other.  This pattern promotes loose coupling by keeping the interacting
        /// objects from referring to each other explicitly.
        /// </summary>
        /// <param name="args"></param>
        static void Main(string[] args)
        {
            ConcessionsMediator mediator = new ConcessionsMediator();

            NorthConcessionStand leftKitchen  = new NorthConcessionStand(mediator);
            SouthConcessionStand rightKitchen = new SouthConcessionStand(mediator);

            mediator.NorthConcessions = leftKitchen;
            mediator.SouthConcessions = rightKitchen;

            leftKitchen.Send("Can you send some popcorn?");
            rightKitchen.Send("Sure thing, Kenny's on his way.");

            rightKitchen.Send("Do you have any extra hot dogs?  We've had a rush on them over here.");
            leftKitchen.Send("Just a couple, we'll send Kenny back with them.");

            Console.ReadKey();
        }