Example #1
0
        public void Disconnect(Connection toDisconnect)
        {
            if (new Connection(Con) == toDisconnect)
            {
                Con.DisconnectOnlyOutputSide(this);
                Con = null;
            }
            else
            {
                bool didDisconnect = false;
                if (CondCons != null)
                {
                    for (int i = 0; i < CondCons.Count; i++)
                    {
                        if (CondCons[i] == toDisconnect)
                        {
                            CondCons[i].From.DisconnectOnlyOutputSide(this);
                            CondCons.RemoveAt(i);
                            didDisconnect = true;
                            break;
                        }
                    }
                }

                if (!didDisconnect)
                {
                    throw new Exception("Can't disconnect from a connection is wasn't connected to.");
                }
            }
        }