private TrafficLightRequest ParseRequest(string request)
 {
     try
     {
         var trafficLightRequest = new TrafficLightRequest();
         foreach (var line in request.Split('\n'))
         {
             string[] phrases = line.Split(' ');
             string url = phrases[1].ToLower();
             if(url.IndexOf("flashing=true") != -1)
             {
                 trafficLightRequest.Flashing = true;
             }
             if (url.IndexOf("solo=true") != -1)
             {
                 trafficLightRequest.Solo = true;
             }
             if(url.Substring(0,6) == "/green")
                 trafficLightRequest.Colour = TrafficLightColour.Green;
             if (url.Substring(0, 4) == "/red")
                 trafficLightRequest.Colour = TrafficLightColour.Red;
             if (url.Substring(0, 6) == "/amber")
                 trafficLightRequest.Colour = TrafficLightColour.Amber;
             return trafficLightRequest;
         }
         if(trafficLightRequest.Colour == TrafficLightColour.NotSpecified)
         {
             throw new InvalidOperationException("Must specify the colour");
         }
         return trafficLightRequest;
     }
     catch(Exception ex)
     {
         throw new NotSupportedException();
     }
 }
 public void SetLed(TrafficLightRequest request)
 {
     if(request.Solo)
     {
         green.State = TrafficLightState.Off;
         amber.State = TrafficLightState.Off;
         red.State = TrafficLightState.Off;
     }
     if(request.Flashing)
     {
         switch(request.Colour)
         {
             case(TrafficLightColour.Green):
                 green.State = TrafficLightState.Flashing;
                 break;
             case(TrafficLightColour.Amber):
                 amber.State = TrafficLightState.Flashing;
                 break;
             case(TrafficLightColour.Red):
                 red.State = TrafficLightState.Flashing;
                 break;
         }
     }
     else
     {
         switch (request.Colour)
         {
             case (TrafficLightColour.Green):
                 green.State = TrafficLightState.On;
                 break;
             case (TrafficLightColour.Amber):
                 amber.State = TrafficLightState.On;
                 break;
             case (TrafficLightColour.Red):
                 red.State = TrafficLightState.On;
                 break;
         }
     }
 }