/// <inheritdoc /> public void RemoveAt(int index) { IComponent component = ComponentsList[index]; ComponentsList.RemoveAt(index); UnsubscribeToComponent(component); CircuitChanged?.Invoke(this, new EventArgs()); }
/// <inheritdoc /> public void Insert(int index, IComponent item) { if (item == null) { throw new ArgumentException("The object is not a component."); } ComponentsList.Insert(index, item); SubscribeToComponent(item); CircuitChanged?.Invoke(this, new EventArgs()); }
/// <inheritdoc /> public bool Remove(IComponent item) { if (item == null) { throw new ArgumentException("The object is not a component."); } if (ComponentsList.Remove(item)) { UnsubscribeToComponent(item); CircuitChanged?.Invoke(this, new EventArgs()); return(true); } return(false); }
/// <inheritdoc /> public void Add(IComponent item) { if (item == null) { throw new ArgumentException("You can not add an object of this type."); } if (FindComponent(item.Name) != null) { throw new ArgumentException("A component with this name already exists."); } ComponentsList.Add(item); SubscribeToComponent(item); CircuitChanged?.Invoke(this, new EventArgs()); }
/// <summary> /// Вызывает событие CircuitChanged, если оно не пустое. /// </summary> public void OnCircuitChanged() { CircuitChanged?.Invoke(this, EventArgs.Empty); }