示例#1
0
        private (TestMessageWriter, ConcreteColleague) CreateConcreteColleague(string name)
        {
            var messageWriter      = new TestMessageWriter();
            var concreateColleague = new ConcreteColleague(name, messageWriter);

            return(messageWriter, concreateColleague);
        }
示例#2
0
        static void Main(string[] args)
        {
            ConcreteMediator  mediator  = new ConcreteMediator();
            ConcreteColleague colleague = new ConcreteColleague(mediator);

            mediator.Register(colleague);

            mediator.Operation();

            Console.ReadKey();
        }
示例#3
0
        public static void EX1()
        {
            Mediator.Exemplo1.Mediator mediator     = new Exemplo1.Mediator();
            ConcreteColleague          participant  = new ConcreteColleague(mediator);
            ConcreteColleague2         participant2 = new ConcreteColleague2(mediator);

            mediator.AddParticipant(participant);
            mediator.AddParticipant(participant2);

            participant.Send("Message");
            participant2.Send("Response of message");
            participant.Send("OK");
            participant2.Send("Bye");
        }