static void Main(string[] args) { var developer = new Person() { DateOfBirth = new DateTime(1987, 08, 20), FirstName = "Christian", LastName = "Nikolov", Height = 187, Id = 35 }; var headOfRecruitment = new Person() { DateOfBirth = new DateTime(1991, 05, 02), FirstName = "Radostina", LastName = "Maneva", Height = 173, Id = 1 }; var chatRoom = new ChatRoom(); var subscriber = new Subscriber("Jonathan Green"); chatRoom.Publish += subscriber.Notify; chatRoom.Add(developer); chatRoom.Add(headOfRecruitment); chatRoom.Schedule(1000 * 60); chatRoom.Remove(); Console.ReadLine(); }
public void AddActor(Actor a) { string id = string.Format("{0}_{1}", a.ActorId, a.ActorName); if (!ChatRoom.ContainsKey(id)) { ChatRoom.Add(id, a); } }
public void GivenAChatRoomThatContains(string chatRoomName, Table table) { var chatRoom = new ChatRoom(chatRoomName); _context.Register(chatRoom); foreach (var row in table.Rows) { var user = _context.LocateUser(row[0]); chatRoom.Add(user); } }
public static void Update(Guid objID, Message message) { var current = GetAll <ChatRoom>(); ChatRoom obj = current.First(r => r.ID == objID); obj.Add(message); File.WriteAllText(fileMap[typeof(ChatRoom)], JsonSerializer.Serialize(current, new JsonSerializerOptions() { WriteIndented = true })); }
private void AddActor(ChatMessage msg) { string id = string.Format("{0}_{1}", msg.ChatActor.ActorId, msg.ChatActor.ActorName); if (!ChatRoom.ContainsKey(id)) { ChatRoom.Add(id, msg.ChatActor); } else { Console.WriteLine("Client with that ID already in chatroom..."); } }
static void Main(string[] args) { var chatRoom = new ChatRoom(); var userFromMobile = new UserFromCellPhone(chatRoom); var userFromDesktop = new UserFromDesktop(chatRoom); var userFromWeb = new UserFromWeb(chatRoom); var observerList = new List <IObserver> { userFromWeb, userFromDesktop, userFromMobile }; chatRoom.Add(observerList); chatRoom.SetState("state 1"); userFromWeb.WriteLastMessageToConsole(); userFromDesktop.WriteLastMessageToConsole(); userFromMobile.WriteLastMessageToConsole(); chatRoom.SetState("state 2"); userFromWeb.WriteMessagesToConsole(); userFromDesktop.WriteMessagesToConsole(); userFromMobile.WriteMessagesToConsole(); var removedObserverList = new List <IObserver> { userFromWeb, userFromDesktop }; chatRoom.Remove(removedObserverList); chatRoom.SetState("state 3"); userFromWeb.WriteMessagesToConsole(); userFromDesktop.WriteMessagesToConsole(); userFromMobile.WriteMessagesToConsole(); userFromWeb.WriteLastMessageToConsole(); userFromDesktop.WriteLastMessageToConsole(); userFromMobile.WriteLastMessageToConsole(); }