Пример #1
0
        public virtual void RemoveConnection(InputPort port)
        {
            if (port == null)
            {
                throw new ArgumentNullException();
            }

            if (_connections.Contains(port))
            {
                _connections.Remove(port);
                ConnectionRemoved?.Invoke(this, new ConnectionModifiedEventArgs(ConnectionModifiedEventArgs.Modifier.Removed, port));
            }
            else
            {
                throw new ArgumentException("element not found", nameof(port));
            }
        }
Пример #2
0
        public void Connect(OutputPort pout, InputPort pin)
        {
            if (pout == null)
            {
                throw new ArgumentNullException();
            }
            if (pin == null)
            {
                throw new ArgumentNullException();
            }

            if (_state != State.Stopped)
            {
                throw new InvalidOperationException("Graph can't be changed when running");
            }

            pout.AddConnection(pin);
        }
Пример #3
0
 /// <summary>
 /// Adds a port to the collection of input ports
 /// </summary>
 /// <param name="port"></param>
 /// <param name="index">Index at which to insert port</param>
 /// <exception cref="ArgumentOutOfRangeException"></exception>
 /// <exception cref="ArgumentException"></exception>
 /// <exception cref="ArgumentNullException"></exception>
 public void AddPort(InputPort port, int index)
 {
     if (port == null)
     {
         throw new ArgumentNullException();
     }
     if (index < 0)
     {
         throw new ArgumentOutOfRangeException();
     }
     if (!_inputs.Contains(port))
     {
         _inputs.Insert(index, port);
         port.ConnectionChanged += Port_ConnectionChanged;
         PortAdded?.Invoke(this, new PortChangedEventArgs(port, index, PortChangedEventArgs.Modifier.Added));
     }
     else
     {
         throw new ArgumentException("Port already exists in collection");
     }
 }
Пример #4
0
        /// <summary>
        /// Adds a remote port to the connection list.
        /// Port must be an input.
        /// </summary>
        /// <param name="port"></param>
        /// <exception cref="ArgumentNullException"></exception>
        /// <exception cref="TypeAccessException"></exception>
        public virtual void AddConnection(InputPort port)
        {
            if (port == null)
            {
                throw new ArgumentNullException();
            }

            if (!port.DataType.Equals(DataType))
            {
                throw new PortTypeMismatchException(DataType, port.DataType);
            }

            if (!_connections.Contains(port))
            {
                _connections.Add(port);
                port.Connection = this;
                ConnectionAdded?.Invoke(this, new ConnectionModifiedEventArgs(ConnectionModifiedEventArgs.Modifier.Added, port));
            }
            else
            {
                throw new ArgumentException("element already exists", nameof(port));
            }
        }
Пример #5
0
        public void Disconnect(OutputPort pout, InputPort pin)
        {
            if (pout == null)
            {
                throw new ArgumentNullException();
            }
            if (pin == null)
            {
                throw new ArgumentNullException();
            }
            if (!(pout.Connections.Contains(pin) && pin.Connection == pout))
            {
                throw new InvalidOperationException();
            }

            if (_state != State.Stopped)
            {
                throw new InvalidOperationException("Graph can't be changed when running");
            }

            pout.RemoveConnection(pin);
            pin.Connection = null;
        }
Пример #6
0
 /// <summary>
 /// Adds a port to the collection of input ports
 /// </summary>
 /// <param name="port"></param>
 /// <exception cref="ArgumentException"></exception>
 /// <exception cref="ArgumentNullException"></exception>
 public void AddPort(InputPort port)
 {
     AddPort(port, _inputs.Count);
 }
Пример #7
0
 public ConnectedEventArgs(InputPort p)
 {
     Port = p;
 }