private void CheckConnectionRec(Communication com, CommunicationBus newBus) { if (com == null || newBus == null || com.Bus == newBus) { return; } com.ChangeBus(newBus); CheckConnectionRec(com.GetLeftCommunication(), newBus); CheckConnectionRec(com.GetRightCommunication(), newBus); CheckConnectionRec(com.GetTopCommunication(), newBus); CheckConnectionRec(com.GetBottomCommunication(), newBus); }
private void ChangeBus(CommunicationBus bus) { if (Bus != null) { Bus.Communications.Remove(this); } if (bus == null) { bus = new CommunicationBus(); } bus.Communications.Add(this); Bus = bus; }