public CustomerProcess()
 {
     welcome = new Welcome( this );
     shop = new Shop( this );
     purchase = new Purchase( this );
     exit = new Exit( this );
 }
        public override void Register(Colleague colleague)
        {
            if (!colleagues.ContainsValue(colleague))
            {
                colleagues[colleague.Name] = colleague;
            }

            colleague.Chatroom = this;
        }
示例#3
0
 public void PostMessage(Colleague sender, string message)
 {
     foreach (Colleague c in ColleagueList)
     {
         if (c != sender)
         {
             c.ReceiveMessage(message, sender.Name);
         }
     }
 }
 public override void Send(string message,
   Colleague colleague)
 {
     if (colleague == _colleague1) {
         _colleague2.Notify(message);
     }
     else {
         _colleague1.Notify(message);
     }
 }
 public override void Send(string message, Colleague colleague)
 {
     if (colleague == colleague1)
     {
     colleague2.Notify(message);
     }
     else
     {
     colleague1.Notify(message);
     }
     //throw new NotImplementedException();
 }
        public override void Send(string message,
                                  Colleague colleague)
        {
            if (colleague == _colleague1)
            {
                _colleague2.Notify(message);
            }
            else

            {
                _colleague1.Notify(message);
            }
        }
示例#7
0
        //public void Register(Colleague colleague)
        //{
        //    colleague.Mediator = this;
        //    _colleagues.Add(colleague);
        //}

        //public T CreateCollegue<T>() where T : Colleague, new()
        //{
        //    var c = new T {Mediator = this};
        //    _colleagues.Add(c);
        //    return c;
        //}

        public void Send(string message, Colleague colleague)
        {
            if (colleague == Colleague1)
            {
                Colleague2.HandleNotification(message);
            }
            else
            {
                Colleague1.HandleNotification(message);
            }

            //_colleagues.Where(c => c != colleague).ToList().ForEach(c => c.HandleNotification(message));
        }
示例#8
0
 public override void Send(string msg, Colleague colleague)
 {
     if (Customer == colleague)
     {
         Programmer.Notify(msg);
     }
     else if (Programmer == colleague)
     {
         Tester.Notify(msg);
     }
     else if (Tester == colleague)
     {
         Customer.Notify(msg);
     }
 }
示例#9
0
 public override void Send(string msg, Colleague colleague)
 {
     if (colleague == Client)
     {
         Waiter.Notify(msg);
     }
     else if (colleague == Waiter)
     {
         Cheff.Notify(msg);
     }
     else if (colleague == Cheff)
     {
         Client.Notify(msg);
     }
 }
 public override void Send(string order, Colleague colleague)
 {
     if (colleague == Waiter)
     {
         if (orders.Contains(order) == false)
         {
             orders.Add(order);
             Cook.MakeOrder(order);
         }
     }
     else if (colleague == Cook)
     {
         Waiter.GiveAnOrder(order);
     }
 }
示例#11
0
 public override void send(Colleague c, String message)
 {
     if (c == cc1)
     {
         cc2.Notify(message);
     }
     else if (c == cc2)
     {
         cc1.Notify(message);
     }
     else
     {
         Console.WriteLine("invalid message!!!");
     }
 }
示例#12
0
        public override void Send(string msg, Colleague colleague)
        {
            /* если отправитель - исполнитель, значит продукт готов
             * отправляем сообщение представителю*/
            if (Executor == colleague)
            {
                Executor.Notify(msg);
            }

            /* если отправитель - представитель,
             * отправляем сообщение заказчику*/
            else if (Representative == colleague)
            {
                Representative.Notify(msg);
            }
        }
示例#13
0
        static void Main(string[] args)
        {
            var mediator = new ConcreteMediator();;
//            Colleague1 c1 = new Colleague1();
//            mediator.Register(c1);
//            Colleague2 c2 = new Colleague2();     call Create colleague as single statement instead of both
//            mediator.Register(c2);

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

            Colleague c1 = mediator.CreateColleague <Colleague1>();
            Colleague c2 = mediator.CreateColleague <Colleague2>();

            mediator.Send("a message", c1);
            mediator.Send("another message", c2);
        }
示例#14
0
        static void Main(string[] args)
        {
            Mediator   m       = new Mediator();
            Colleague  head1   = new Colleague(m, "John");
            ColleagueB branch1 = new ColleagueB(m, "David");
            Colleague  head2   = new Colleague(m, "Lucy");

            head1.Send("Meeting on Tuesday, please all ack");
            branch1.Send("Ack");
            m.Block(branch1.Receive);
            head1.Send("Still awaiting some Acks");
            head2.Send("Ack");
            m.Unblock(branch1.Receive);
            head1.Send("Thanks all");

            Console.ReadLine();
        }
示例#15
0
        static void Sample2()
        {
            Sample2.Mediator m       = new Sample2.Mediator();
            Colleague        head1   = new Colleague(m, "John");
            ColleagueB       branch1 = new ColleagueB(m, "David");
            Colleague        head2   = new Colleague(m, "Lucy");

            head1.Send("Meeting on Tuesday, please all ack");
            branch1.Send("Ack");

            m.Block(branch1.Receive);
            head1.Send("Still awaiting some Acks");
            head2.Send("Ack");

            m.Unblock(branch1.Receive);
            head1.Send("Thanks all");
        }
示例#16
0
        public override void Send(string message, Colleague colleague)
        {
            if (Customer == colleague)
            {
                Programmer.Notify(message);
            }

            if (colleague == Programmer)
            {
                Tester.Notify(message);
            }

            if (colleague == Tester)
            {
                Customer.Notify(message);
            }
        }
示例#17
0
 public override void RelatedChange(Colleague colleague)
 {
     if (colleague is Manager)
     {
         Mgr.AddTask();
         Dev.DevTask();
         Tes.TestTask();
     }
     else if (colleague is Develop)
     {
         Dev.SolveProblem();
         Tes.VerifyProblem();
     }
     else if (colleague is Test)
     {
         Tes.FindProblem();
         Mgr.Supervise();
         Dev.SolveProblem();
     }
 }
示例#18
0
 public override void Send(string msg, Colleague colleague)
 {
     // если отправитель - завод, значит есть продукт
     // отправляем сообщение курьеру - доставить продукцию
     if (Factory == colleague)
     {
         Courier.Notify(msg);
     }
     // если отправитель - курьер, значит товар доставлен
     // отправляем сообщение в магазин
     else if (Courier == colleague)
     {
         Shop.Notify(msg);
     }
     // если отправитель - магазин, значит продукция сбыта
     // отправляем сообщение заводу
     else if (Shop == colleague)
     {
         Factory.Notify(msg);
     }
 }
示例#19
0
 public override void Send(string message, Colleague colleague)
 {
     // Если отправитель - заказчик, значит есть новый заказ
     // отправляем сообщение программисту - выполнить заказ
     if (Customer == colleague)
     {
         Programmer.Notify(message);
     }
     // Если отправитель - программист, то можно приступать к тестированию
     // отправляем сообщение тестеру
     else if (Programmer == colleague)
     {
         Tester.Notify(message);
     }
     // Если отправитель - тест, значит продукт готов
     // отправляем сообщение заказчику
     else if (Tester == colleague)
     {
         Customer.Notify(message);
     }
 }
示例#20
0
        private void btnGo_Click(object sender, EventArgs e)
        {
            Colleague colleagueBob   = new Colleague("Bob");
            Colleague colleagueSue   = new Colleague("Sue");
            Colleague colleagueChris = new Colleague("Chris");
            Colleague colleagueDonna = new Colleague("Donna");

            IMediator mediator1 = new Mediator();

            mediator1.Register(colleagueBob);
            mediator1.Register(colleagueSue);
            mediator1.Register(colleagueChris);

            colleagueBob.SendMessage(mediator1, "Hi folks!");

            IMediator mediator2 = new Mediator();

            mediator2.Register(colleagueSue);
            mediator2.Register(colleagueDonna);

            colleagueSue.SendMessage(mediator2, "A more private message.");
        }
示例#21
0
 public override void Register(Colleague colleague)
 {
     _mediator.Add(colleague.name, colleague);
     colleague.chatroom = this;
 }
示例#22
0
 public abstract string Send(string msg, Colleague colleague);
示例#23
0
 public override void Send(string message, Colleague colleague)
 {
     colleagues.Where(c => c != colleague).ToList().ForEach(c => c.HandleNotification(message));
 }
示例#24
0
 public void Register(Colleague colleague)
 {
     colleague.SetMediator(this);
     colleagues.Add(colleague);
 }
示例#25
0
 public abstract void Send(string message,
   Colleague colleague);
示例#26
0
 public abstract void Send(string msg, Colleague colleague);
示例#27
0
 public void Register(Colleague colleague)
 {
     ColleagueList.Add(colleague);
 }
示例#28
0
 public abstract void send(Colleague mediator, String message);
示例#29
0
 public void Register(Colleague colleague)
 {
     ColleagueList.Add(colleague);
 }
示例#30
0
 public abstract void pushMessage(string message, Colleague enty);
 public abstract void Register(Colleague colleague);
示例#32
0
 public abstract void Send(Colleague _from, string msg);
示例#33
0
 public void AddColleague(Colleague a)
 {
     a.SetMediator(this);
     colleague.Add(a);
 }
示例#34
0
 public abstract void Register(Colleague colleague);
示例#35
0
 public void Add(Colleague subscriber)
 {
     colleagues.Add(subscriber);
 }
示例#36
0
 public abstract void Send(string message, Colleague colleague);
示例#37
0
 public abstract void RelatedChange(Colleague colleague);
示例#38
0
 public void Send(string message, Colleague colleague)
 {
     mediator.Send(message, colleague);
 }
示例#39
0
 public void Send(string message, Colleague colleague)
 {
     if (colleague == colleague1)
     {
         colleague1.Notify(message);
     }
     else if (colleague == colleague2)
     {
         colleague2.Notify(message);
     }
 }