/// <summary> /// 移除房间 /// </summary> /// <param name="room">房间对象</param> public void RemoveRoom(Room room) { Exception ex = null; if (room != null) { if (!string.IsNullOrEmpty(room.Name) && "all" != room.Name.Trim()) { if (rooms == null) { ex = new Exception("房间列表不存在,已将其重新初始化。"); rooms = new List<Room>(); } else { if (rooms.Remove(room)) { ex = new Exception("从房间列表中移除房间成功。"); } else { ex = new Exception("房间在房间列表中不存在。"); } } } else { ex = new Exception("房间名称不能为" + (string.IsNullOrEmpty(room.Name) ? "空" : "all") + "。"); } } else { ex = new Exception("房间对象不能为空。"); } UpdateEventArgs arg = new UpdateEventArgs(ex); OnRemoveRoom(arg); }
/// <summary> /// 添加房间 /// </summary> /// <param name="room">房间对象</param> public void AddRoom(Room room) { Exception ex = null; if (room != null) { if (!string.IsNullOrEmpty(room.Name) && "all" != room.Name.Trim()) { if (rooms == null) { ex = new Exception("房间列表重新初始化,添加房间成功。"); rooms = new List<Room>(); rooms.Add(room); } else { if (rooms.Contains(room)) { ex = new Exception("房间已经存在于房间列表中。"); } else { ex = new Exception("添加房间成功。"); rooms.Add(room); } } } else { ex = new Exception("房间名称不能为" + (string.IsNullOrEmpty(room.Name) ? "空" : "all") + "。"); } } else { ex = new Exception("房间对象不能为空。"); } UpdateEventArgs arg = new UpdateEventArgs(ex); OnAddRoom(arg); }