private void AddOrRemoveOrEdit(Action action, Class currentClass) { try { string currentName = (action == Action.Add) ? ChooseName(currentClass) : ChooseNameFromList(currentClass); MyDictionary currentDictionary = GetDictionary(currentClass); AnyTransportClass currentElement = GetElement(currentClass, currentName); switch (action) { case Action.Remove: currentDictionary.RemoveElement(currentName); break; case Action.Edit: currentDictionary.EditElement(currentElement, currentName); break; case Action.Add: currentDictionary.AddElement(currentElement, currentName); break; } } catch (Exception e) { MessageBox.Show(e.Message); } }
public void AddElement(AnyTransportClass element, string name) { try { CurrentDictionary.Add(name, element); foreach (Selector dependency in Dependencies) { if (!dependency.Items.Contains(name)) { dependency.Items.Add(name); // dependency.Items.Refresh(); } } } catch { throw new Exception($"Element {name} already exists"); } }
public void EditElement(AnyTransportClass element, string name) { CurrentDictionary[name] = element; }