Ejemplo n.º 1
0
 public static void AddItem2(ItemBase item)
 {
     if (item == null)
     {
         throw new Exception("参数不能为空.");
     }
     if (commandTable.ContainsKey(item.Name))
     {
         throw new Exception("名称已存在.");
     }
     commandTable.Add(item.Name, item);
 }
Ejemplo n.º 2
0
 public CommandChangedArgs(ItemBase item, EnumChangeType type, object value)
 {
     this.CommandItem = item;
     this.ChangeType = type;
     this.Value = value;
 }
Ejemplo n.º 3
0
 public void AddItem(ItemBase item)
 {
     if (dtItems == null)
     {
         dtItems = new List<ItemBase>();
     }
     if (item == null)
     {
         throw new Exception("参数不能为空.");
     }
     if (Contains(item.Name))
     {
         throw new Exception("名称已存在.");
     }
     dtItems.Add(item);
     if (commandChangedEvent != null)
     {
         CommandChangedArgs args = new CommandChangedArgs(item, CommandChangedArgs.EnumChangeType.Add, null);
         commandChangedEvent(null,args);
     }
 }
Ejemplo n.º 4
0
 public bool RemoveItem(ItemBase item)
 {
     if (dtItems == null)
     {
         dtItems = new List<ItemBase>();
     }
     if (item == null)
     {
         throw new Exception("参数不能为空.");
     }
     if (commandChangedEvent != null)
     {
         CommandChangedArgs args = new CommandChangedArgs(item, CommandChangedArgs.EnumChangeType.Remove, null);
         commandChangedEvent(null, args);
     }
     return dtItems.Remove(item);
 }
Ejemplo n.º 5
0
 public static void RemoveItem2(ItemBase item)
 {
     if (item == null)
     {
         throw new Exception("参数不能为空.");
     }
     if (commandTable.ContainsKey(item.Name))
     {
         commandTable.Remove(item.Name);
     }
     else
     {
         throw new Exception("不存在.");
     }
 }