Ejemplo n.º 1
0
        static void MediatorExample()
        {
            var mediator   = new ConcreteMediator();
            var colleague1 = new Colleague1(mediator);
            var colleague2 = new Colleague2(mediator);

            mediator.Colleague1 = colleague1;
            mediator.Colleague2 = colleague2;

            colleague1.Send($"Hello {nameof(Colleague2)}!");
            colleague2.Send($"Hello {nameof(Colleague1)}!");
        }
Ejemplo n.º 2
0
        /// <summary>
        /// The main.
        /// </summary>
        /// <param name="args">
        /// The args.
        /// </param>
        public static void Main(string[] args)
        {
            var mediator = new Mediator();

            /* var colleague1 = new Colleague1();
             * var colleague2 = new Colleague2();
             *
             * mediator.Register(colleague1);
             * mediator.Register(colleague2); */

            Colleague1 colleague1 = mediator.CreateColleague <Colleague1>();
            Colleague2 colleague2 = mediator.CreateColleague <Colleague2>();

            colleague1.Send($"Hello Word from colleague 1");
            colleague2.Send($"Hello Word from colleague 2");
        }
        static void Main(string[] args)
        {
            var mediator = new ConcreteMediator();

            var c1 = new Colleague1();
            var c2 = new Colleague2();

            //mediator.Colleague1 = c1;
            //mediator.Colleague2 = c2;

            mediator.Register(c1);
            mediator.Register(c2);

            c1.Send("Hello from c1");
            c2.Send("Hola from c2");
            //mediator.Send("Hola", c2);
        }
Ejemplo n.º 4
0
        public void Run()
        {
            var mediator = new ConcreteMediator();
            var c1       = new Colleague1(mediator);
            var c2       = new Colleague2(mediator);

            mediator.Colleague1 = c1;
            mediator.Colleague2 = c2;

            //mediator.Register(c1);
            //mediator.Register(c2);

            //var c1 = mediator.CreateCollegue<Colleague1>();
            //var c2 = mediator.CreateCollegue<Colleague2>();

            c1.Send("Hello c2!");
            c2.Send("Hello c1!");
        }