title: Nested switch? Or other solution checking different conditions?
body: <p>Okay, the situation is as following:</p>
  
  <p>I have one client that has 2 settings: ConnectionState and ConnectionSollState, both the same enumerable (TypeConnectionState), they store the actual state of the client connection and the state the connection should be. On every combination of the to, something different should happen, like when ConnectionState is "Connected" but ConnectionSollState is "Closed" -> Teardown the client. So I have like 4 possibilities that I have to check.
  Now every client can handle an infinite number of sessions, and every session has also a state (StreamState &amp; StreamSollState), those states can have 6 options in enumerable.</p>
  
  <p>From now on, I'm making like 20 switch-conditions and my code looks really messy, I'm doing something wrong every 5 minutes while coding. Is there an easier way to handle a situation like this? (if/else) would make things waaay worse.</p>
  
  <p>Example:</p>
  
  <pre><code>private void RTSPWorker() {
      try {
          byte[] buffer = new byte[2048];
          while (!mb_RTSPWorkerAbbort) {
          // Call TransportWD
              Thread.Sleep(100 * mi_ConnectionTimeOut);
  
              // Check ConnectionSollState
              switch(ConnectionSollState) {
                  case TypeConnectionState.Connected:
                      // ConnectionSollState = Connected, check ConnectionState
                      switch(ConnectionState) {
                          case TypeConnectionState.Connected:
                              // ConnectionState is connected, keep-alive!
                              if(GET_PARAMETER() == null) {
                                  DESCRIBE();
                              }
                              // Check streams too
                              foreach (cRTSPStream oStream in mo_StreamDict.Values) {
                                  // Check StreamSollState
                                  switch(oStream.RTSPStreamSollState) {
                                      case cRTSPStream.TypeRTSPStreamState.Play:
                                          // SollState is PLAY, check State
                                          switch(oStream.RTSPStreamState) {
                                              case cRTSPStream.TypeRTSPStreamState.Play:
                                                  //Stream is alive, keep-alive!
                                                  if (oStream.PLAY() == null) { oStream.DESCRIBE(); } break;
                                              case cRTSPStream.TypeRTSPStreamState.Closed:
                                                  // Reinitialise.
                                                  if (oStream.SETUP() != null) { oStream.PLAY(); } break;
                                              default:
                                                  // Default, send play.
                                                  oStream.PLAY(); break;
                                          }
                                      break;
                                  case cRTSPStream.TypeRTSPStreamState.Pause:
                                      // SollState is on pause, check State
                                      switch(oStream.RTSPStreamState) {
                                          case cRTSPStream.TypeRTSPStreamState.Closed:
                                              // Reinitialise.
                                              if (oStream.SETUP() != null) { oStream.PLAY(); } break;
                                          default:
                                              oStream.PAUSE();
                                              break;
                                      }
                                  break;
                                  case cRTSPStream.TypeRTSPStreamState.Closed:
                                      // SollState is closed, check State
                                      switch(oStream.RTSPStreamState) {
                                          case cRTSPStream.TypeRTSPStreamState.Closed:
                                              // Is closed, do nothing
                                              break;
                                          default:
                                              // Default teardown, remove session
                                              oStream.TEARDOWN();
                                              this.RemoveRTSPSession(oStream);
                                              break;
                                          }
                                  default:
                                      // Default, what do?
                                      break;
                                  }
                              }
                              break;
                          case TypeConnectionState.Closed:
                              // ConnectionState should be connected, re-connect!
                                  while(Connect() != true) {
                                      // Sleep for 200ms, try again
                                      Thread.Sleep(200);
                                  }
                              break;
                          default:
                              // TODO anything else
                              break;
                      }
                      break;
                  case TypeConnectionState.Closed:
                      // Check ConnectionState
                      switch(ConnectionState) {
                          case TypeConnectionState.Connected:
                              // Is connected, should be closed. Close connection &amp; clean up!
                              Close(null);
                              break;
                          default:
                              // Anything other than Connected, do nothing.
                              break;
                      }
                      break;
  
                  default:
                      break;
              }
          }
      } catch {
  
      }
  }
  </code></pre>