diff --git a/Ior/Core/ResponseBodyOutput.cs b/Ior/Core/ResponseBodyOutput.cs
index 1b09b42..a5ddbe2 100644
--- a/Ior/Core/ResponseBodyOutput.cs
+++ b/Ior/Core/ResponseBodyOutput.cs
@@ -1,5 +1,5 @@
namespace Swensen.Ior.Core {
public enum ResponseBodyOutput {
- Hex, Plain, Pretty, Rendered
+ Hex, Plain, Pretty, Rendered, Regex
}
}
\ No newline at end of file
diff --git a/Ior/Forms/MainForm.Designer.cs b/Ior/Forms/MainForm.Designer.cs
index 008dd6b..dd7b883 100644
--- a/Ior/Forms/MainForm.Designer.cs
+++ b/Ior/Forms/MainForm.Designer.cs
@@ -52,6 +52,9 @@ private void InitializeComponent()
this.tpResponseText = new System.Windows.Forms.TabPage();
this.pnlResponseContent = new System.Windows.Forms.Panel();
this.grpResponseBodyOutput = new System.Windows.Forms.GroupBox();
+ this.rbResponseBodyOutputRegex = new System.Windows.Forms.RadioButton();
+ this.txtRegex = new System.Windows.Forms.TextBox();
+ this.btnApplyRegex = new System.Windows.Forms.Button();
this.rbResponseBodyOutputHex = new System.Windows.Forms.RadioButton();
this.rbResponseBodyOutputBrowser = new System.Windows.Forms.RadioButton();
this.rbResponseBodyOutputPretty = new System.Windows.Forms.RadioButton();
@@ -429,6 +432,9 @@ private void InitializeComponent()
//
this.grpResponseBodyOutput.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.grpResponseBodyOutput.Controls.Add(this.rbResponseBodyOutputHex);
+ this.grpResponseBodyOutput.Controls.Add(this.rbResponseBodyOutputRegex);
+ this.grpResponseBodyOutput.Controls.Add(this.txtRegex);
+ this.grpResponseBodyOutput.Controls.Add(this.btnApplyRegex);
this.grpResponseBodyOutput.Controls.Add(this.rbResponseBodyOutputBrowser);
this.grpResponseBodyOutput.Controls.Add(this.rbResponseBodyOutputPretty);
this.grpResponseBodyOutput.Controls.Add(this.rbResponseBodyOutputPlain);
@@ -454,6 +460,44 @@ private void InitializeComponent()
this.rbResponseBodyOutputHex.Text = "Hex";
this.rbResponseBodyOutputHex.UseVisualStyleBackColor = true;
//
+ // rbResponseBodyOutputRegex
+ //
+ this.rbResponseBodyOutputRegex.AutoSize = true;
+ this.rbResponseBodyOutputRegex.Location = new System.Drawing.Point(470, 33);
+ this.rbResponseBodyOutputRegex.Margin = new System.Windows.Forms.Padding(6);
+ this.rbResponseBodyOutputRegex.Name = "rbResponseBodyOutputRegex";
+ this.rbResponseBodyOutputRegex.Size = new System.Drawing.Size(81, 29);
+ this.rbResponseBodyOutputRegex.TabIndex = 15;
+ this.rbResponseBodyOutputRegex.TabStop = true;
+ this.rbResponseBodyOutputRegex.Text = "Regex";
+ this.rbResponseBodyOutputRegex.UseVisualStyleBackColor = true;
+ //
+ // txtRegex
+ //
+ this.txtRegex.AutoSize = true;
+ this.txtRegex.Location = new System.Drawing.Point(584, 33);
+ this.txtRegex.Margin = new System.Windows.Forms.Padding(6);
+ this.txtRegex.Name = "txtRegex";
+ this.txtRegex.Size = new System.Drawing.Size(300, 29);
+ this.txtRegex.TabIndex = 15;
+ this.txtRegex.TabStop = true;
+ this.txtRegex.Visible = false;
+ this.txtRegex.Enter += new System.EventHandler(this.txtRegex_Enter);
+ this.txtRegex.Leave += new System.EventHandler(this.txtRegex_Leave);
+ //
+ // btnApplyRegex
+ //
+ this.btnApplyRegex.AutoSize = true;
+ this.btnApplyRegex.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
+ this.btnApplyRegex.Location = new System.Drawing.Point(895, 29);
+ this.btnApplyRegex.Margin = new System.Windows.Forms.Padding(6);
+ this.btnApplyRegex.Name = "btnApplyRegex";
+ this.btnApplyRegex.Size = new System.Drawing.Size(88, 35);
+ this.btnApplyRegex.TabIndex = 8;
+ this.btnApplyRegex.Text = "Apply";
+ this.btnApplyRegex.UseVisualStyleBackColor = true;
+ this.btnApplyRegex.Click += new System.EventHandler(this.btnApplyRegex_Click);
+ //
// rbResponseBodyOutputBrowser
//
this.rbResponseBodyOutputBrowser.AutoSize = true;
@@ -1050,6 +1094,9 @@ private void InitializeComponent()
private System.Windows.Forms.StatusStrip mainStatusStrip;
private System.Windows.Forms.ToolStripStatusLabel lblLogNotifications;
private System.Windows.Forms.RadioButton rbResponseBodyOutputHex;
+ private System.Windows.Forms.RadioButton rbResponseBodyOutputRegex;
+ private System.Windows.Forms.TextBox txtRegex;
+ private System.Windows.Forms.Button btnApplyRegex;
private System.Windows.Forms.ToolStripMenuItem exportPrettyResponseBodyToolStripMenuItem;
private StandardTextBox txtHttpOther;
}
diff --git a/Ior/Forms/MainForm.cs b/Ior/Forms/MainForm.cs
index 4c675ba..2f79a34 100644
--- a/Ior/Forms/MainForm.cs
+++ b/Ior/Forms/MainForm.cs
@@ -14,6 +14,7 @@
using NLog;
using System.Xml;
using System.Xml.Serialization;
+using System.Text.RegularExpressions;
//examples response types:
//xml: http://www.w3schools.com/xml/note.asp
@@ -258,6 +259,7 @@ private void bindResponseBodyOutputs() {
rbResponseBodyOutputPlain.Tag = ResponseBodyOutput.Plain;
rbResponseBodyOutputPretty.Tag = ResponseBodyOutput.Pretty;
rbResponseBodyOutputBrowser.Tag = ResponseBodyOutput.Rendered;
+ rbResponseBodyOutputRegex.Tag = ResponseBodyOutput.Regex;
foreach (var rb in rbGrpResponseBodyOutputs) {
rb.CheckedChanged += new EventHandler(rbGrpResponseBodyOutput_CheckedChanged);
@@ -279,18 +281,24 @@ private void updateResponseBodyOutput() {
txtResponseText.Visible = false;
wbResponseBody.Visible = false;
bvResponseBody.Visible = true;
+ txtRegex.Visible = false;
+ btnApplyRegex.Visible = false;
bvResponseBody.SetBytes(lastResponseModel.ContentBytes ?? new byte[0]);
break;
case ResponseBodyOutput.Plain:
txtResponseText.Visible = true;
wbResponseBody.Visible = false;
bvResponseBody.Visible = false;
+ txtRegex.Visible = false;
+ btnApplyRegex.Visible = false;
txtResponseText.Text = lastResponseModel.Content;
break;
case ResponseBodyOutput.Pretty:
txtResponseText.Visible = true;
wbResponseBody.Visible = false;
bvResponseBody.Visible = false;
+ txtRegex.Visible = false;
+ btnApplyRegex.Visible = false;
txtResponseText.Text = lastResponseModel.PrettyPrintedContent;
var mtc = lastResponseModel.ContentType.MediaTypeCategory;
txtResponseText.ConfigurationManager.Language =
@@ -305,6 +313,8 @@ private void updateResponseBodyOutput() {
txtResponseText.Visible = false;
wbResponseBody.Visible = true;
bvResponseBody.Visible = false;
+ txtRegex.Visible = false;
+ btnApplyRegex.Visible = false;
if ((lastResponseModel.ContentType.MediaTypeCategory == IorMediaTypeCategory.Xml ||
lastResponseModel.ContentType.MediaTypeCategory == IorMediaTypeCategory.Application) &&
@@ -325,9 +335,41 @@ private void updateResponseBodyOutput() {
break;
}
}
-
wbResponseBody.Refresh();
- break;
+ break;
+ case ResponseBodyOutput.Regex:
+ txtResponseText.Visible = true;
+ wbResponseBody.Visible = false;
+ bvResponseBody.Visible = false;
+ txtRegex.Visible = true;
+ btnApplyRegex.Visible = true;
+
+ String content = lastResponseModel.Content;
+ String response = content;
+
+ if (content != null && txtRegex.Text != "") {
+ Regex rx = null;
+
+ try {
+ rx = new Regex(txtRegex.Text);
+ } catch {
+ MessageBox.Show("Incorrect regex. Please enter correct Regex.");
+ }
+
+ if (rx != null) {
+ MatchCollection matches = rx.Matches(content);
+ response = "";
+
+ foreach (Match match in matches)
+ {
+ response += match.Value + Environment.NewLine;
+ }
+ }
+ }
+
+ txtResponseText.Text = response;
+ break;
+
}
}
@@ -349,6 +391,18 @@ private void cancelAsyncRequest() {
bind(ResponseModel.Empty);
}
}
+
+ private void txtRegex_Enter(object sender, EventArgs e) {
+ this.AcceptButton = btnApplyRegex;
+ }
+
+ private void txtRegex_Leave(object sender, EventArgs e) {
+ this.AcceptButton = btnSubmitRequest;
+ }
+
+ private void btnApplyRegex_Click(object sender, EventArgs e) {
+ updateResponseBodyOutput();
+ }
private void btnSubmitRequest_Click(object sender, EventArgs e)
{
@@ -604,6 +658,10 @@ private void txtRequestBody_TextChanged(object sender, EventArgs e) {
private void txtRequestHeaders_TextChanged(object sender, EventArgs e) {
setIsLastOpenedRequestFileDirtyToTrue();
}
+
+ private void txtRegex_TextChanged(object sender, EventArgs e) {
+ updateResponseBodyOutput();
+ }
//scintilla does not support link clicked event
//private void txtResponseText_LinkClicked(object sender, LinkClickedEventArgs e) {
diff --git a/Ior/Ior.csproj b/Ior/Ior.csproj
index a844074..8bf3b94 100644
--- a/Ior/Ior.csproj
+++ b/Ior/Ior.csproj
@@ -76,6 +76,7 @@
True
+