public virtual IColleague FindColleague(IColleague colleague) { int mode = colleague.Mode; var coll = Colleagues.ToList <IColleague>().Find(delegate(IColleague cg) { return(cg.Mode == mode); }); return(coll); }
public virtual void Introduce(IColleague <T> provider, IColleague <T> consumer) { IList <IColleague <T> > consumers = new List <IColleague <T> >(); this.provider = provider; this.consumers = consumers; }
public void register(IColleague <T> newColleague) { lock (_lockObj) { _colleagues.Add(newColleague); } }
public void unregister(IColleague <T> Colleague) { lock (_lockObj) { _colleagues.Remove(Colleague); } }
public void Register(IColleague colleague, params string[] topics) { _colleagues.Add(new ColleagueInfo( colleague, topics.Select(t => t.Trim().ToLower())) ); }
/// <summary> /// Registers a Colleague to a specific message /// </summary> /// <param name="colleague">The colleague to register</param> /// <param name="messages">The message to register to</param> public void Register(IColleague colleague, IEnumerable <string> messages) { foreach (string message in messages) { internalList.AddValue(message, colleague); } }
public void Register(IColleague <T> provider, params IColleague <T>[] consumers) { this.provider = provider; if (consumers != null && consumers.Length > 0) { this.consumers = new List <IColleague <T> >(consumers); } }
public void RemoveColleague(IColleague colleague) { if (!Colleagues.Contains(colleague)) { return; } Colleagues.Remove(colleague); }
public virtual void Introduce(IColleague <T> provider, params IColleague <T>[] consumers) { if (consumers.Length > 0) { IList <IColleague <T> > array = new List <IColleague <T> >(consumers); this.consumers = array; } this.provider = provider; }
public virtual void Registor(IColleague colleague) { var coll = FindColleague(colleague); if (coll == null) { Colleagues.Add(colleague); } }
public void Listen(string message, IColleague colleague) { // If source is self, ignore. if (colleague == this) { return; } Console.WriteLine($"{colleague.Name} to {Name} : '{message}'"); }
public void NotifyAll(string message, IColleague authorColleague) { Console.WriteLine($"[Mediator] Message from author '{authorColleague.Name}' : {message}"); foreach (var colleague in colleagues) { colleague.Receive(message); } }
public virtual void UnRegistor(IColleague colleague) { var coll = FindColleague(colleague.Mode); if (coll != null) { Colleagues.Remove(colleague); } }
public void HandleRequest(IColleague colleague, string request) { foreach (var col in _listOfColleagues) { if (col != colleague) { col.ReceiveRequest(request); } } }
public void broadcastMsg(IColleague <T> from, T msg) { foreach (IColleague <T> c in _colleagues) { if (c != from || from == null) { c.receiveMsg(msg); } } }
public void Distribute(IColleague sender, string messageContents) { foreach (IColleague colleague in _colleagues .Where(c => c != sender) ) { IMessage message = new Message(sender.Name, messageContents); colleague.Receive(message); } }
public MediatorWeight(decimal weightOption, decimal weightCredit, decimal weightLoan) { this._weightOption = weightOption; this._weightCredit = weightCredit; this._weightLoan = weightLoan; this.Option = new OptionColleague(); this.Credit = new CreditColleague(); this.Loan = new LoanColleague(); }
void IMediator <T> .DistributeMessage(IColleague <T> sender, T message) { foreach (IColleague <T> c in colleagueList) { if (c != sender) //don't need to send message to sender { c.ReceiveMessage(message); } } }
public void DistributeMessage(IColleague <T> sender, T message) { foreach (var colleague in this.ColleagueList) { if (colleague != sender) { colleague.ReceiveMessage(message); } } }
public void SendMessage(string message, IColleague colleague) { foreach (var x in ColleagueList) { if (x != colleague) { Console.WriteLine("\n" + colleague.Name + " has sent: " + message + " to " + x.Name + "\n"); x.Receive(this, message); } } }
public void Send(object message, IColleague colleague) { if (colleague == _uploadFileViewModel) { _selectInputVariablesViewModel.Receive(message); _selectOutputVariablesViewModel.Receive(message); } OnPropertyChanged(nameof(SelectInputVariablesViewModel)); OnPropertyChanged(nameof(SelectOutputVariablesViewModel)); }
public void Send(string message, IColleague colleague) { if (colleague == FirstColleague) { ConcreteColleague2.Notify(message); } else { ConcreteColleague1.Notify(message); } }
public void RegisterColleague(IColleague colleague) { if (Colleagues.Contains(colleague)) { return; } colleague.SetMediator(this); Colleagues.Add(colleague); }
public void DistributeMessage(IColleague <T> sender, T message) { foreach (var c in this._colleagueList) { // not to send itself if (c != sender) { c.ReceiveMessage(message); } } }
public void Send(string msg, IColleague coll) { if (coll == Jack) { Jhon.Notify(msg); } else if (coll == Jhon) { Jack.Notify(msg); } }
public void ExecuteCommand(string command, IColleague receiver, params object[] args) { switch (command) { case "Listen": { (receiver as PlayerServiceProxyColleague).Listen(receiver.BondedColleague as Player, args[0] as LogicFacade); break; } } }
public void DistributeMessage(IColleague <T> sender, T message) { foreach (IColleague <T> colleague in colleagueList) { //Excpet for sender, Distribute the message to all the Registered collagues if (colleague != sender) { colleague.RecieveMessage(message); } } }
public void Register(IColleague colleague) { if (!registered.Contains(colleague)) { registered.Add(colleague); colleague.Mediator = this; if (colleague.BondedColleague != null) { colleague.BondedColleague.Mediator = this; } } }
public void NotifyAll(string message, IColleague sender) { foreach (IColleague colleague in colleagues) { if (colleague == sender) { continue; } colleague.Receive($"{message} from {sender}"); } }
public void SendMessage(IColleague sender, string type, string content) { foreach (IColleague colleague in Colleagues) { if (colleague == sender) { continue; } colleague.ReceiveMessage(type, content); } }
/// <summary> /// Registers a Colleague to a specific message /// </summary> /// <param name="colleague">The colleague to register</param> /// <param name="messages">The message to register to</param> public void Register(IColleague colleague, IEnumerable<string> messages) { foreach (string message in messages) { if (!_internalList.ContainsKey(message)) { _internalList[message] = new List<IColleague>(1); } else { if (_internalList[message] == null) _internalList[message] = new List<IColleague>(1); } _internalList[message].Add(colleague); } }
/// <summary> /// 中介者可以动态地与某个同事建立联系 /// </summary> /// <param name="name"></param> /// <param name="colleague"></param> public void AddColleague(String name, IColleague colleague) { //在中介者这里帮助具体同事建立起于中介者的联系 colleague.SetMediator(this); this.Colleagues.Add(name, colleague); }
/// <summary> /// Registers a Colleague to a specific message /// </summary> /// <param name="colleague">The colleague to register</param> /// <param name="messages">The message to register to</param> public void Register(IColleague colleague, IEnumerable<string> messages) { foreach (string message in messages) internalList.AddValue(message, colleague); }