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); }
public CommandChangedArgs(ItemBase item, EnumChangeType type, object value) { this.CommandItem = item; this.ChangeType = type; this.Value = value; }
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); } }
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); }
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("不存在."); } }