예제 #1
0
        public Mediator(Component1 component1, Component2 component2)
        {
            _component1 = component1;
            _component1.SetMediator(this);

            _component2 = component2;
            _component2.SetMediator(this);
        }
예제 #2
0
        public void TestMethod1()
        {
            // create the components

            var component1 = new Component1();
            var component2 = new Component2();

            // create the mediator

            var mediator = new Mediator(component1, component2);

            // set the mediator for each component

            component1.SetMediator(mediator);
            component2.SetMediator(mediator);

            // perform some action to see if the mediator tells the other component

            component1.DoSomething();
            component1.DoSomethingElse();

            component2.DoSomething();
            component2.DoSomethingElse();
        }