static void Demo() { Mediator m = new Mediator(); Colleague chat1 = new Colleague(m, "John"); Colleague chat2 = new Colleague(m, "David"); Colleague chat3 = new Colleague(m, "Lucy"); }
// Methods override public 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 (colleague1 == colleague) { 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); } }
public void ApplyLevel(int id, int amount) { if (mDataArr[id].Level == 0) { Colleague newCol = Instantiate(mPrefabArr[id]); newCol.transform.position = mSpawnPos.position; newCol.Init(id, mDataArr[id].JobTime); mSpawnedList.Add(newCol); } mDataArr[id].Level += amount; // 2020.01.02 목요일 - 코드 추가 CalcAndShowData(id); }
public override void Send(Message message, Colleague from) { if (from is Player) { Messages.Add(message); } //if (from is Game) //{ // message.Author = new Player(); // message.Author.Name = "Game"; // Messages.Add(message); //} }
public override void Send(string message, Colleague colleague) { if (colleague == Farmer) { // если позвонил фермер по поводу помидоров - передаем на прозиводство Manufactore.MakeKetchup(message); } else if (colleague == Manufactore) { // если позвонил зовод, то посредник звонит в магазин - размещать товар. Shop.SellKetchup(message); } }
// 收到来自Colleague的通知请求 public override void SendMessage(Colleague theColleague, string Message) { // 收到Colleague1通知Colleague2 if (m_Colleague1 == theColleague) { m_Colleague2.Request(Message); } // 收到Colleague2通知Colleague1 if (m_Colleague2 == theColleague) { m_Colleague1.Request(Message); } }
public override void Send(string message, Colleague colleague) { if (colleague == Customer) { Programmer.Notify(message); } else if (colleague == Programmer) { Tester.Notify(message); } else { Customer.Notify(message); } }
/// <summary> /// Method signature for sending messages to another colleague. /// </summary> /// <param name="message">Message to send.</param> /// <param name="col">Colleague to send to.</param> /// <returns><c>bool</c> - returns that message was sent and received.</returns> public override bool Send(string message, Colleague col) { if (col == Colleague1) { return(Colleague1.Notify(message)); } if (col == Colleague2) { return(Colleague2.Notify(message)); } // No colleagues found. return(false); }
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); } }
private void saveProfile(ref Colleague colleague, IFormFile profile) { if (profile != null) { colleague.picName = Guid.NewGuid() + Path.GetExtension(profile.FileName); string picPath = _hostingEnvironment.WebRootPath + @"\images\Profiles\" + colleague.picName; using (var stream = new FileStream(picPath, FileMode.Create)) { profile.CopyTo(stream); } } }
public void ApplyLevel2(int id, int amount) { if (mDataArr[id].Level == 0) { Colleague newCol = Instantiate(mPrefabArr[id]); newCol.transform.position = mSpawnPos.position; newCol.Init(id, mDataArr[id].JobTime); mSpawnedList.Add(newCol); } mDataArr[id].Level += amount; mDataArr[id].ValueCurrent = mDataArr[id].ValueBase * Math.Pow(mDataArr[id].ValueWeight, mDataArr[id].Level); mDataArr[id].CostCurrent = mDataArr[id].CostBase * Math.Pow(mDataArr[id].CostWeight, mDataArr[id].Level); mElementList[id].Renew(mDataArr[id].Contents, "구매", mDataArr[id].Level, mDataArr[id].ValueCurrent, mDataArr[id].CostCurrent, mDataArr[id].JobTime); }
static void MainRun() { Mediator m = new Mediator(); // Two from head office and one from a branch office 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"); // by design does not get a copy m.Block(branch1.Receive); // temporarily gets no messages head1.Send("Still awaiting some Acks"); head2.Send("Ack"); m.Unblock(branch1.Receive); //open again head1.Send("Thanks all"); }
public override void Execute(Colleague Bar) { var target = Bar.GetComponent <BarManager>(); if (target is BarManager) { target.SelectedSeat.IsPatronGoesOnQuestDeciderActive(false); target.SelectedSeat.PatronWantsToTalkAboutWaitingInABar(); //target.setBarState(target.pauseAtTheEndOfCancelAdventure()); //target.setBarState(target.patronIsConversing()); target.setBarState(target.noOneInteractedWith()); // target.ClickPatron(); //target.BackOutOfAdventureMap(); } base.Execute(Bar); }
public void Mediator_Test() { var mediator = new Mediator(); var A = new Colleague(mediator); var B = new Colleague(mediator); mediator.colleagueA = A; mediator.colleagueB = B; A.Message = "Mike"; A.Send(); var lastMsg = B.LastMessage; Assert.IsTrue(lastMsg.Contains(A.Message)); }
public void ApplyLevel(int id, int amount) { if (mDataArr[id].Level == 0) { Colleague newCol = Instantiate(mPrefabArr[id]); newCol.transform.position = mSpawnPos.position; newCol.Init(id, mDataArr[id].JobTime); mSpawnedList.Add(newCol); } mDataArr[id].Level += amount; mLevelArr[id] = mDataArr[id].Level; CalcAndShowData(id); //UnityEngine.Random.Range(0,3); }
public JsonResult SendRequest(Colleague colleague) { var jsonSuccessResult = new JsonSuccessResult(); try { Colleagues.Insert(colleague); string fullName = colleague.FirstName + " " + colleague.LastName; // اطلاع رسانی به مدیر #region Apprise Admin string body = "مدیریت محترم، در بخش همکاری با ما، پیام جدیدی ثبت شد:"; body += "<br/>"; body += String.Format("نام و نام خانوادگی: {0} <br/> زمینه همکاری: {1} <br/> شماره همراه: {2} <br/> پست الکترونیک: {3}", fullName, colleague.CooperationDescription, colleague.Mobile, colleague.Email); EmailServices.NotifyAdminsByEmail(AdminEmailType.NewColleague, body, null); #endregion Apprise Admin EmailServices.DeliveryColleagueRequest(colleague.Email, fullName, UserID); jsonSuccessResult.Success = true; } catch (DbException ex) { jsonSuccessResult.Errors = ex.Errors.ToArray(); jsonSuccessResult.Success = false; } catch (Exception ex) { jsonSuccessResult.Errors = new string[] { ex.Message }; jsonSuccessResult.Success = false; } return(new JsonResult() { Data = jsonSuccessResult }); }
public void Load(int[] levelArr) { // 2020.01.07 화요일 - 코드 수정 //for(int i = 0; i < levelArr.Length; i++) for (int i = 0; i < mDataArr.Length; i++) { mDataArr[i].Level = levelArr[i]; CalcAndShowData(i); if (mDataArr[i].Level > 0) { Colleague newCol = Instantiate(mPrefabArr[i]); newCol.transform.position = mSpawnPos.position; newCol.Init(i, mDataArr[i].JobTime); mSpawnedList.Add(newCol); } } }
public ActionResult Edit(Colleague colleague) { try { colleague.LastUpdate = DateTime.Now; ViewBag.Success = true; Colleagues.Update(colleague); } catch (Exception ex) { SetErrors(ex); } return(RedirectToAction("Index")); }
//public ConcreteColleague1 Colleague1 //{ // set { _colleague1 = value; } //} //public ConcreteColleague2 Colleague2 //{ // set { _colleague2 = value; } //} public override void Send(string message, Colleague colleague) { //if (colleague == _colleague1) //{ // _colleague2.Notify(message); //} //else //{ // _colleague1.Notify(message); //} foreach (var item in colleagues) { if (item != colleague) { item.Notify(message); } } }
// Start is called before the first frame update void Start() { Colleague col = new Colleague(); CreateRefColleague(ref col); // CreateColleague(col); // CreateInColleague(col); Colleague co; CreateOutColleague(out co); Debug.Log(col.Name + " " + col.Sex); // Debug.Log(co.Name + " " + co.Sex); int n = 1; IncrementInt(ref n); Debug.Log(n); }
// 2020.01.02 목요일 - 함수 추가 public void Load(int[] levelArr) { for (int i = 0; i < levelArr.Length; i++) { // PlayerInfoController.cs에서 mInfos가 여기에서 mDataArr과 동일한 기능을 하는 변수이다. // 이름을 통일시키는 것이 좋다. mDataArr[i].Level = levelArr[i]; CalcAndShowData(i); if (mDataArr[i].Level >= 0) { Colleague newCol = Instantiate(mPrefabArr[i]); newCol.transform.position = mSpawnPos.position; newCol.Init(i, mDataArr[i].JobTime); mSpawnedList.Add(newCol); } } }
public void TestMediator() { var mediator = new Mediator <string>(); var colleague1 = new Colleague <string>("Colleague 1"); var colleague2 = new Colleague <string>("Colleague 2"); var colleague3 = new Colleague <string>("Colleague 3"); mediator.Register(colleague1); mediator.Register(colleague2); mediator.Register(colleague3); colleague1.SendMessage(mediator, "Test message 1"); // OUTPUT: Colleague 2 received Test message 1. // OUTPUT: Colleague 3 received Test message 1. }
public void ColleagueChanged(Colleague colleague) { System.Console.WriteLine("Mediator ColleagueChanged"); if (colleague == colleague1) { if (colleague1.Status == colleague2.Status) { colleague2.ChangeStatus(!colleague1.Status); } } else if (colleague == colleague2) { if (colleague2.Status == colleague1.Status) { colleague1.ChangeStatus(!colleague2.Status); } } }
/// <summary> /// 中介者模式 /// </summary> private static void HandleMediator() { AbstractMediator mediator = new QQMediator(); AbstractColleague colleague = new Colleague(mediator); colleague.UserName = "******"; AbstractColleague colleague2 = new Colleague(mediator); colleague2.UserName = "******"; mediator.Add(colleague); mediator.Add(colleague2); //发送消息 colleague.Send("灵儿", "你好"); colleague.Send("紫涵", "早上好~"); Console.Read(); }
public void Kill() { if (invoicesPaid > 0) { bool killMade = false; Colleague colleague = Colleagues[invoicesPaid - 1]; if (!colleague.Dead) { colleague.Dead = true; cashToCome = (cashToCome + colleague.cash); killMade = true; kills++; PlayerPrefs.SetInt("kills", kills); // TODO: trigger new scene Debug.Log("You've killed: " + colleague.name); Application.LoadLevel(Application.loadedLevel + 1); } /*foreach (Colleague colleague in Colleagues) { * Debug.Log ("Checking if colleague is alive: " + colleague.name + ", dead:" + colleague.Dead); * if (!colleague.Dead) { * colleague.Dead = true; * cashToCome = (cashToCome + colleague.cash); * killMade = true; * kills++; * // TODO: trigger new scene * Debug.Log ("You've killed: " + colleague.name); * pushStory(); * break; * } * }*/ if (!killMade) { Debug.Log("They are all dead! Pay your invoices"); } } else { Debug.Log("Make some cash"); } }
public async Task <ActionResult <Colleague> > PostColleague(Colleague colleague) { _context.Colleague.Add(colleague); try { await _context.SaveChangesAsync(); } catch (DbUpdateException) { if (ColleagueExists(colleague.ColleagueId)) { return(Conflict()); } else { throw; } } return(CreatedAtAction("GetColleague", new { id = colleague.ColleagueId }, colleague)); }
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); } }
public override void NotifyChange(string message, Colleague colleague) { var isValid = true; isValid = !( (message.IndexOf(" are") >= 0) || (message.IndexOf("are ") >= 0) || (message.IndexOf(" you") >= 0) || (message.IndexOf(" you") >= 0) || (message.IndexOf(" thanks") >= 0) || (message.IndexOf("thanks ") >= 0) ); if (isValid) { base.NotifyChange(message, colleague); } else { Console.WriteLine("\tPlease use chat words: 'u', 'r' and tnx' instead of 'you', 'are' and 'thanks'."); } }
public async Task <IActionResult> Edit(int id, [Bind("ColleagueID,Name,PhoneNumber,BirthDay,StartActivity,code,color,isMale")] Colleague colleague, IFormFile profile) { if (id != colleague.ColleagueID) { ViewBag.err = new NotFoundException(); return(View("Error")); } if (ModelState.IsValid) { try { Colleague Edited = await colleagues.GetByIdAsync(id); Edited.BirthDay = colleague.BirthDay; Edited.code = colleague.code; Edited.color = colleague.color; Edited.isMale = colleague.isMale; Edited.StartActivity = colleague.StartActivity; Edited.Name = colleague.Name; if (profile != null) { deleteProfile(id); saveProfile(ref Edited, profile); } await colleagues.UpdateAsync(Edited); await colleagues.saveAsync(); } catch (Exception ex) { ViewBag.err = ex; return(View("Error")); } return(RedirectToAction("Details", new { id = colleague.ColleagueID })); //RedirectToAction(nameof(Index)); } return(View(colleague)); }
private void OnEmployeeServiceOpenReadComplete(object sender, OpenReadCompletedEventArgs e) { var reader = new StreamReader(e.Result); var result = reader.ReadToEnd(); XmlReader XMLReader = XmlReader.Create(new MemoryStream(System.Text.UnicodeEncoding.Unicode.GetBytes(result))); XDocument data = XDocument.Load(XMLReader); var query = from emp in data.Elements("employee") select new Colleague { ColleagueID = emp.Element("guid").Value, FirstName = emp.Element("firstname").Value, LastName = emp.Element("lastname").Value, Title = emp.Element("title").Value, CurrentLocation = emp.Element("currentlocation").Value, PhotoURL = string.Format("http://{0}", emp.Element("photourl").Value), ThumbnailURL = string.Format("http://{0}", emp.Element("thumbnailurl").Value), MobilePhone = emp.Element("mobilephonenumber").Value }; colleague = query.SingleOrDefault(); this.DataContext = colleague; }
public async Task <IActionResult> Create([Bind("ColleagueID,Name,PhoneNumber,code,color,isMale")] Colleague colleague, IFormFile profile, string BirthDay, string StartActivity) { if (ModelState.IsValid) { try { colleague.BirthDay = Convert.ToDateTime(BirthDay.ToAD()); colleague.StartActivity = Convert.ToDateTime(StartActivity.ToAD()); } catch (Exception) { this.SetViewMessage("Please Complete fields ...", WebMessageType.Warning); return(RedirectToAction("Colleagues", "Home")); } saveProfile(ref colleague, profile); try { await colleagues.InsertAsync(colleague); await colleagues.saveAsync(); this.SetViewMessage("New Colleague Created successfully.", WebMessageType.Success); } catch (Exception ex) { this.SetViewMessage(ex.Message, WebMessageType.Danger); } } else { this.SetViewMessage("Please Complete fields ...", WebMessageType.Warning); } return(RedirectToAction("Colleagues", "Home")); }
public void Send(string message, Colleague colleague) { if (colleague == colleague1) { colleague1.Notify(message); } else if (colleague == colleague2) { colleague2.Notify(message); } }
private void buildColleagueTreeRecursive(int iParentID, Colleague colleague, TreeNodeCollection nodeCollection) { IEnumerable<Folder> listColleagueFolders = Globals.ThisAddIn.user.LoadColleagueFolders(colleague.ServerAddress, colleague.UserID, iParentID); foreach (Folder folder in listColleagueFolders) { TreeNode nodeFolder = new TreeNode(); nodeFolder.Name = "colleaguefolder_" + folder.ID; nodeFolder.Text = folder.Name; nodeFolder.Tag = colleague; nodeFolder.ImageKey = nodeFolder.SelectedImageKey = getMappedFolderImage(folder.Type); nodeCollection.Add(nodeFolder); buildColleagueTreeRecursive(folder.ID, colleague, nodeFolder.Nodes); } }
private void loadItems(bool bFiltering, string filter, bool bFromColleague, Colleague colleague, string strFolderID) { try { if (selectedFolder != null || bFromColleague) { if (bFiltering) { if (masterThread.IsAlive && masterThread.Name == "loadingitems") masterThread.Abort(); ParameterizedThreadStart threadStart = new ParameterizedThreadStart(masterControlThread.FilterItems); masterThread = new Thread(threadStart); masterThread.Name = "loadingitems"; Dictionary<string, object> data = new Dictionary<string, object>(); data["ItemList"] = itemList; data["Filter"] = filter; masterThread.Start(data); } else { if (masterThread.IsAlive && masterThread.Name == "loadingitems") masterThread.Abort(); inputSearch.Enabled = false; prepareLoadingItemsLabel(); if (bFromColleague) { ParameterizedThreadStart threadStart = new ParameterizedThreadStart(masterControlThread.LoadColleagueItems); masterThread = new Thread(threadStart); masterThread.Name = "loadingitems"; Dictionary<string, object> data = new Dictionary<string, object>(); data["Colleague"] = colleague; data["FolderID"] = strFolderID; masterThread.Start(data); } else { ParameterizedThreadStart threadStart = new ParameterizedThreadStart(masterControlThread.LoadItems); masterThread = new Thread(threadStart); masterThread.Name = "loadingitems"; masterThread.Start(selectedFolder.ID); } } } } catch (Exception ex) { log.WriteLine(LogType.Error, "MasterControl::loadItems", ex.ToString()); } }
public abstract void Register(Colleague colleague);
public abstract void Send(string message, Colleague @from, Colleague to);
public abstract void Send(string message, Colleague colleague);
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); }
public void Main() { var m = new Mediator(); // Two from head office and one from a branch office var head1 = new Colleague(m, "John"); var branch1 = new ColleagueB(m, "David"); var head2 = new Colleague(m, "Lucy"); head1.Send("Meeting on Tuesday, please all ack"); branch1.Send("Ack"); // by design does not get a copy m.Block(branch1.Receive); // temporarily gets no messages head1.Send("Still awaiting some Acks"); head2.Send("Ack"); m.Unblock(branch1.Receive); // open again head1.Send("Thanks all"); }