Пример #1
0
        /// <inheritdoc />
        public void RemoveAt(int index)
        {
            IComponent component = ComponentsList[index];

            ComponentsList.RemoveAt(index);
            UnsubscribeToComponent(component);
            CircuitChanged?.Invoke(this, new EventArgs());
        }
Пример #2
0
        /// <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());
        }
Пример #3
0
 /// <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);
 }
Пример #4
0
        /// <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());
        }
Пример #5
0
 /// <summary>
 /// Вызывает событие CircuitChanged, если оно не пустое.
 /// </summary>
 public void OnCircuitChanged()
 {
     CircuitChanged?.Invoke(this, EventArgs.Empty);
 }