Пример #1
0
 /// <summary>
 /// 引发处理更新区域名称的事件
 /// </summary>
 /// <param name="e">事件参数</param>
 private void OnUpdateName(UpdateEventArgs e)
 {
     if (this.UpdateNameCompleted != null)
     {
         this.UpdateNameCompleted(this, e);
     }
 }
Пример #2
0
 /// <summary>
 /// 引发处理添加房间的事件
 /// </summary>
 /// <param name="e">事件参数</param>
 private void OnAddRoom(UpdateEventArgs e)
 {
     if (this.AddRoomCompleted != null)
     {
         this.AddRoomCompleted(this, e);
     }
 }
Пример #3
0
 /// <summary>
 /// 引发处理使住所成为主要住所的事件
 /// </summary>
 /// <param name="e">事件参数</param>
 private void OnBecomePrimary(UpdateEventArgs e)
 {
     if (this.BecomePrimaryCompleted != null)
     {
         this.BecomePrimaryCompleted(this, e);
     }
 }
Пример #4
0
 /// <summary>
 /// 引发处理移除房间的事件
 /// </summary>
 /// <param name="e">事件参数</param>
 private void OnRemoveRoom(UpdateEventArgs e)
 {
     if (this.RemoveRoomCompleted != null)
     {
         this.RemoveRoomCompleted(this, e);
     }
 }
Пример #5
0
        /// <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);
        }
Пример #6
0
        /// <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);
        }
Пример #7
0
        /// <summary>
        /// 更新区域名称
        /// </summary>
        /// <param name="name">区域名称</param>
        public void UpdateName(string name)
        {
            Exception ex = null;

            if (string.IsNullOrEmpty(name))
            {
                ex = new Exception("区域名称不能为空。");
            }
            else if (Name == name.Trim())
            {
                ex = new Exception("新区域名称与旧区域名称没有变化。");
            }
            else if ("all" == name.Trim())
            {
                ex = new Exception("新区域名称不能为all。");
            }
            else
            {
                Name = name.Trim();
                ex = new Exception("区域名称更新成功。");
            }

            UpdateEventArgs arg = new UpdateEventArgs(ex);
            OnUpdateName(arg);
        }
Пример #8
0
        /// <summary>
        /// 使住所成为主要住所
        /// </summary>
        public void BecomePrimary()
        {
            Exception ex = null;
            string name = "[" + (Name ?? "null") + "]";

            if (IsPrimary)
            {
                ex = new Exception(name + "已经是主要住所。");
            }
            else
            {
                IsPrimary = true;
                ex = new Exception("设置" + name + "为主要住所成功。");
            }

            UpdateEventArgs arg = new UpdateEventArgs(ex);
            OnBecomePrimary(arg);
        }