public IEnumerable <XElement> TwimlVerbs() { while (MyCall.CallStatus != CallStatus.Ended) { if (CurrentNode == null) { var allNodes = Twiml.Element("Response").Elements(); if (allNodes.Count() == 0) { // no nodes at all!!!!! yield break; } CurrentNode = allNodes.First(); } else { // we need to process siblings if (CurrentNode.NextElement() == null) { // no siblings // set it to the parent node // if we currenttl are the gather node then zero it out first CurrentNode = CurrentNode.Parent; } else { //set it to tthe next sibling if (GatherNode == CurrentNode) { GatherNode = null; } CurrentNode = CurrentNode.NextElement(); // Set the parent node as the active one } }; if (CurrentNode.Name.ToString().ToUpper() == "RESPONSE") { // we are done yield break; } // if its the gather verb then set that as the gethernode and lift the current emenet to the gather child // unless we are the gather verb then just continue if (GatherNode == null && CurrentNode.Name.ToString().ToUpper() == "GATHER") { // its teh gather verb // set it as the gathernode GatherNode = CurrentNode; // if there are children(play etc...,) then set them as the current node // else keep it to the gather var decs = CurrentNode.Descendants(); if (decs.Count() > 0) { CurrentNode = decs.First(); } } yield return(CurrentNode); } }
/// <summary> /// Generate the necessary parameters /// </summary> public List <KeyValuePair <string, string> > GetParams() { var p = new List <KeyValuePair <string, string> >(); if (To != null) { p.Add(new KeyValuePair <string, string>("To", To.ToString())); } if (From != null) { p.Add(new KeyValuePair <string, string>("From", From.ToString())); } if (Url != null) { p.Add(new KeyValuePair <string, string>("Url", Serializers.Url(Url))); } if (Twiml != null) { p.Add(new KeyValuePair <string, string>("Twiml", Twiml.ToString())); } if (ApplicationSid != null) { p.Add(new KeyValuePair <string, string>("ApplicationSid", ApplicationSid.ToString())); } if (Method != null) { p.Add(new KeyValuePair <string, string>("Method", Method.ToString())); } if (FallbackUrl != null) { p.Add(new KeyValuePair <string, string>("FallbackUrl", Serializers.Url(FallbackUrl))); } if (FallbackMethod != null) { p.Add(new KeyValuePair <string, string>("FallbackMethod", FallbackMethod.ToString())); } if (StatusCallback != null) { p.Add(new KeyValuePair <string, string>("StatusCallback", Serializers.Url(StatusCallback))); } if (StatusCallbackEvent != null) { p.AddRange(StatusCallbackEvent.Select(prop => new KeyValuePair <string, string>("StatusCallbackEvent", prop))); } if (StatusCallbackMethod != null) { p.Add(new KeyValuePair <string, string>("StatusCallbackMethod", StatusCallbackMethod.ToString())); } if (SendDigits != null) { p.Add(new KeyValuePair <string, string>("SendDigits", SendDigits)); } if (Timeout != null) { p.Add(new KeyValuePair <string, string>("Timeout", Timeout.ToString())); } if (Record != null) { p.Add(new KeyValuePair <string, string>("Record", Record.Value.ToString().ToLower())); } if (RecordingChannels != null) { p.Add(new KeyValuePair <string, string>("RecordingChannels", RecordingChannels)); } if (RecordingStatusCallback != null) { p.Add(new KeyValuePair <string, string>("RecordingStatusCallback", RecordingStatusCallback)); } if (RecordingStatusCallbackMethod != null) { p.Add(new KeyValuePair <string, string>("RecordingStatusCallbackMethod", RecordingStatusCallbackMethod.ToString())); } if (SipAuthUsername != null) { p.Add(new KeyValuePair <string, string>("SipAuthUsername", SipAuthUsername)); } if (SipAuthPassword != null) { p.Add(new KeyValuePair <string, string>("SipAuthPassword", SipAuthPassword)); } if (MachineDetection != null) { p.Add(new KeyValuePair <string, string>("MachineDetection", MachineDetection)); } if (MachineDetectionTimeout != null) { p.Add(new KeyValuePair <string, string>("MachineDetectionTimeout", MachineDetectionTimeout.ToString())); } if (RecordingStatusCallbackEvent != null) { p.AddRange(RecordingStatusCallbackEvent.Select(prop => new KeyValuePair <string, string>("RecordingStatusCallbackEvent", prop))); } if (Trim != null) { p.Add(new KeyValuePair <string, string>("Trim", Trim)); } if (CallerId != null) { p.Add(new KeyValuePair <string, string>("CallerId", CallerId)); } if (MachineDetectionSpeechThreshold != null) { p.Add(new KeyValuePair <string, string>("MachineDetectionSpeechThreshold", MachineDetectionSpeechThreshold.ToString())); } if (MachineDetectionSpeechEndThreshold != null) { p.Add(new KeyValuePair <string, string>("MachineDetectionSpeechEndThreshold", MachineDetectionSpeechEndThreshold.ToString())); } if (MachineDetectionSilenceTimeout != null) { p.Add(new KeyValuePair <string, string>("MachineDetectionSilenceTimeout", MachineDetectionSilenceTimeout.ToString())); } if (AsyncAmd != null) { p.Add(new KeyValuePair <string, string>("AsyncAmd", AsyncAmd)); } if (AsyncAmdStatusCallback != null) { p.Add(new KeyValuePair <string, string>("AsyncAmdStatusCallback", Serializers.Url(AsyncAmdStatusCallback))); } if (AsyncAmdStatusCallbackMethod != null) { p.Add(new KeyValuePair <string, string>("AsyncAmdStatusCallbackMethod", AsyncAmdStatusCallbackMethod.ToString())); } if (Byoc != null) { p.Add(new KeyValuePair <string, string>("Byoc", Byoc.ToString())); } if (CallReason != null) { p.Add(new KeyValuePair <string, string>("CallReason", CallReason)); } return(p); }