Beispiel #1
0
 public override ActionBase GetAction()
 {
     if (!string.IsNullOrEmpty(this.WebRequestURLTextBox.Text))
     {
         WebRequestResponseActionTypeEnum responseType = EnumHelper.GetEnumValueFromString <WebRequestResponseActionTypeEnum>((string)this.ResponseActionComboBox.SelectedItem);
         if (responseType == WebRequestResponseActionTypeEnum.Chat)
         {
             if (!string.IsNullOrEmpty(this.ChatResponseTextBox.Text))
             {
                 return(WebRequestAction.CreateForChat(this.WebRequestURLTextBox.Text, this.ChatResponseTextBox.Text));
             }
         }
         else if (responseType == WebRequestResponseActionTypeEnum.Command)
         {
             if (this.CommandResponseComboBox.SelectedIndex >= 0)
             {
                 return(WebRequestAction.CreateForCommand(this.WebRequestURLTextBox.Text, (CommandBase)this.CommandResponseComboBox.SelectedItem, this.CommandResponseArgumentsTextBox.Text));
             }
         }
         else if (responseType == WebRequestResponseActionTypeEnum.SpecialIdentifier)
         {
             if (!string.IsNullOrEmpty(this.SpecialIdentifierResponseTextBox.Text) && this.SpecialIdentifierResponseTextBox.Text.All(c => Char.IsLetterOrDigit(c)))
             {
                 return(WebRequestAction.CreateForSpecialIdentifier(this.WebRequestURLTextBox.Text, this.SpecialIdentifierResponseTextBox.Text));
             }
         }
         else
         {
             return(new WebRequestAction(this.WebRequestURLTextBox.Text, WebRequestResponseActionTypeEnum.None));
         }
     }
     return(null);
 }
 public override ActionBase GetAction()
 {
     if (!string.IsNullOrEmpty(this.WebRequestURLTextBox.Text))
     {
         WebRequestResponseActionTypeEnum responseType = EnumHelper.GetEnumValueFromString <WebRequestResponseActionTypeEnum>((string)this.ResponseActionComboBox.SelectedItem);
         if (responseType == WebRequestResponseActionTypeEnum.Chat)
         {
             if (!string.IsNullOrEmpty(this.ChatResponseTextBox.Text))
             {
                 return(WebRequestAction.CreateForChat(this.WebRequestURLTextBox.Text, this.ChatResponseTextBox.Text));
             }
         }
         else if (responseType == WebRequestResponseActionTypeEnum.Command)
         {
             if (this.CommandResponseComboBox.SelectedIndex >= 0)
             {
                 return(WebRequestAction.CreateForCommand(this.WebRequestURLTextBox.Text, (CommandBase)this.CommandResponseComboBox.SelectedItem, this.CommandResponseArgumentsTextBox.Text));
             }
         }
         else if (responseType == WebRequestResponseActionTypeEnum.SpecialIdentifier)
         {
             if (!string.IsNullOrEmpty(this.SpecialIdentifierResponseTextBox.Text) && SpecialIdentifierStringBuilder.IsValidSpecialIdentifier(this.SpecialIdentifierResponseTextBox.Text))
             {
                 return(WebRequestAction.CreateForSpecialIdentifier(this.WebRequestURLTextBox.Text, this.SpecialIdentifierResponseTextBox.Text));
             }
         }
         else if (responseType == WebRequestResponseActionTypeEnum.JSONToSpecialIdentifiers)
         {
             if (this.jsonToSpecialIdentifierPairs.Count > 0)
             {
                 foreach (JSONToSpecialIdentifierPair pairs in this.jsonToSpecialIdentifierPairs)
                 {
                     if (string.IsNullOrEmpty(pairs.JSONParameterName) || !SpecialIdentifierStringBuilder.IsValidSpecialIdentifier(pairs.SpecialIdentifierName))
                     {
                         return(null);
                     }
                 }
                 return(WebRequestAction.CreateForJSONToSpecialIdentifiers(this.WebRequestURLTextBox.Text,
                                                                           this.jsonToSpecialIdentifierPairs.ToDictionary(p => p.JSONParameterName, p => p.SpecialIdentifierName)));
             }
         }
         else
         {
             return(new WebRequestAction(this.WebRequestURLTextBox.Text, WebRequestResponseActionTypeEnum.None));
         }
     }
     return(null);
 }