实例介绍
【实例简介】
【实例截图】
【核心代码】 private void actDoExport(Session[] oSelectedSessions)
{
string[] array = FiddlerApplication.oTranscoders.getExportFormats();
if (array.Length > 0)
{
if (oSelectedSessions == null)
{
oSelectedSessions = this.GetAllSessions();
}
Array.Sort<string>(array);
string sExportFormat = actSelectImportExportFormat(false, array);
if (sExportFormat != null)
{
Application.DoEvents();
if (FiddlerApplication.DoExport(sExportFormat, oSelectedSessions, null, null))
{
this.sbpInfo.Text = "Export to " sExportFormat " completed.";
}
}
}
else
{
FiddlerApplication.DoNotifyUser("You can install Exporters from http://www.fiddler2.com/redir/?id=FIDDLERTRANSCODERS", "No Exporters Installed");
}
}
[CodeDescription("Launch the Find Sessions user experience.")]
public void actDoFind()
{
frmSearch search = new frmSearch {
cbSearchSelectedSessions = { Enabled = this.lvSessions.SelectedItems.Count > 0, Checked = this.lvSessions.SelectedItems.Count > 1 }
};
if (DialogResult.OK == search.ShowDialog(this))
{
IEnumerable selectedItems;
int num = 0;
if (search.cbSearchSelectedSessions.Checked)
{
selectedItems = this.lvSessions.SelectedItems;
}
else
{
selectedItems = this.lvSessions.Items;
}
System.Drawing.Color empty = System.Drawing.Color.Empty;
if (search.cbxSearchColor.SelectedIndex > 0)
{
empty = System.Drawing.Color.FromName(search.cbxSearchColor.Text);
}
if (search.cbSearchSelectMatches.Checked)
{
FiddlerApplication.SuppressReportUpdates = true;
this.lvSessions.SelectedItems.Clear();
FiddlerApplication.SuppressReportUpdates = false;
}
string text = search.txtSearchFor.Text;
Regex regex = null;
if (search.txtSearchFor.Text.StartsWith("REGEX:", StringComparison.OrdinalIgnoreCase))
{
try
{
RegexOptions options = RegexOptions.Singleline | RegexOptions.ExplicitCapture;
if (!search.cbSearchCaseSensitive.Checked)
{
options |= RegexOptions.IgnoreCase;
}
regex = new Regex(search.txtSearchFor.Text.Substring(6), options);
}
catch (Exception exception)
{
MessageBox.Show("An invalid regular expression was provided.\n" exception.ToString(), "Invalid Regular Expression");
}
}
foreach (ListViewItem item in selectedItems)
{
Session tag = item.Tag as Session;
if (tag != null)
{
bool success;
StringBuilder builder = new StringBuilder();
if (((search.cbxSearchIn.SelectedIndex < 2) && (tag.oRequest != null)) && (tag.oRequest.headers != null))
{
if (search.cbxExamine.SelectedIndex < 2)
{
builder.Append(tag.oRequest.headers.ToString(true, false, true));
}
if ((((search.cbxExamine.SelectedIndex != 1) && (tag.requestBodyBytes != null)) && (tag.requestBodyBytes.Length > 0)) && (search.cbSearchBinaries.Checked || !Utilities.IsBinaryMIME(tag.oRequest["Content-Type"])))
{
if (search.cbSearchDecodeFirst.Checked)
{
tag.utilDecodeRequest();
}
builder.Append(Utilities.getEntityBodyEncoding(tag.oRequest.headers, tag.requestBodyBytes).GetString(tag.requestBodyBytes));
}
}
if (((search.cbxSearchIn.SelectedIndex == 0) || (search.cbxSearchIn.SelectedIndex == 2)) && ((tag.oResponse != null) && (tag.oResponse.headers != null)))
{
if (search.cbxExamine.SelectedIndex != 2)
{
builder.Append(tag.oResponse.headers.ToString(true, false));
}
if ((((search.cbxExamine.SelectedIndex != 1) && (tag.responseBodyBytes != null)) && (tag.responseBodyBytes.Length > 0)) && (search.cbSearchBinaries.Checked || !Utilities.IsBinaryMIME(tag.oResponse["Content-Type"])))
{
if (search.cbSearchDecodeFirst.Checked)
{
tag.utilDecodeResponse();
}
builder.Append(Utilities.getResponseBodyEncoding(tag).GetString(tag.responseBodyBytes));
}
}
if (search.cbxSearchIn.SelectedIndex == 3)
{
builder.Append(tag.fullUrl);
}
string input = builder.ToString();
if (regex != null)
{
success = regex.Match(input).Success;
}
else
{
success = -1 < input.IndexOf(text, search.cbSearchCaseSensitive.Checked ? StringComparison.CurrentCulture : StringComparison.CurrentCultureIgnoreCase);
}
if (success)
{
num ;
if (num == 1)
{
item.EnsureVisible();
}
if (empty != System.Drawing.Color.Empty)
{
if ((tag.oFlags["ui-bold"] != "user-marked") && (item.ForeColor != System.Drawing.Color.Black))
{
tag.oFlags["ui-oldcolor"] = Utilities.GetStringFromColor(item.ForeColor);
}
item.BackColor = empty;
tag.oFlags["ui-backcolor"] = search.cbxSearchColor.Text;
}
if (search.cbSearchSelectMatches.Checked)
{
item.Selected = true;
}
continue;
}
if (search.cbUnmarkOld.Checked && (tag.oFlags["ui-backcolor"] == search.cbxSearchColor.Text))
{
item.BackColor = this.lvSessions.BackColor;
tag.oFlags.Remove("ui-backcolor");
}
}
}
string str3 = "contained";
if (regex != null)
{
str3 = "matched";
}
this.sbpInfo.Text = string.Format("{0} session{1} {2} '{3}'", new object[] { num, (num != 1) ? "s" : string.Empty, str3, (regex == null) ? text : text.Substring(6) });
this.lvSessions.Focus();
}
search.Dispose();
}
【实例截图】
【核心代码】 private void actDoExport(Session[] oSelectedSessions)
{
string[] array = FiddlerApplication.oTranscoders.getExportFormats();
if (array.Length > 0)
{
if (oSelectedSessions == null)
{
oSelectedSessions = this.GetAllSessions();
}
Array.Sort<string>(array);
string sExportFormat = actSelectImportExportFormat(false, array);
if (sExportFormat != null)
{
Application.DoEvents();
if (FiddlerApplication.DoExport(sExportFormat, oSelectedSessions, null, null))
{
this.sbpInfo.Text = "Export to " sExportFormat " completed.";
}
}
}
else
{
FiddlerApplication.DoNotifyUser("You can install Exporters from http://www.fiddler2.com/redir/?id=FIDDLERTRANSCODERS", "No Exporters Installed");
}
}
[CodeDescription("Launch the Find Sessions user experience.")]
public void actDoFind()
{
frmSearch search = new frmSearch {
cbSearchSelectedSessions = { Enabled = this.lvSessions.SelectedItems.Count > 0, Checked = this.lvSessions.SelectedItems.Count > 1 }
};
if (DialogResult.OK == search.ShowDialog(this))
{
IEnumerable selectedItems;
int num = 0;
if (search.cbSearchSelectedSessions.Checked)
{
selectedItems = this.lvSessions.SelectedItems;
}
else
{
selectedItems = this.lvSessions.Items;
}
System.Drawing.Color empty = System.Drawing.Color.Empty;
if (search.cbxSearchColor.SelectedIndex > 0)
{
empty = System.Drawing.Color.FromName(search.cbxSearchColor.Text);
}
if (search.cbSearchSelectMatches.Checked)
{
FiddlerApplication.SuppressReportUpdates = true;
this.lvSessions.SelectedItems.Clear();
FiddlerApplication.SuppressReportUpdates = false;
}
string text = search.txtSearchFor.Text;
Regex regex = null;
if (search.txtSearchFor.Text.StartsWith("REGEX:", StringComparison.OrdinalIgnoreCase))
{
try
{
RegexOptions options = RegexOptions.Singleline | RegexOptions.ExplicitCapture;
if (!search.cbSearchCaseSensitive.Checked)
{
options |= RegexOptions.IgnoreCase;
}
regex = new Regex(search.txtSearchFor.Text.Substring(6), options);
}
catch (Exception exception)
{
MessageBox.Show("An invalid regular expression was provided.\n" exception.ToString(), "Invalid Regular Expression");
}
}
foreach (ListViewItem item in selectedItems)
{
Session tag = item.Tag as Session;
if (tag != null)
{
bool success;
StringBuilder builder = new StringBuilder();
if (((search.cbxSearchIn.SelectedIndex < 2) && (tag.oRequest != null)) && (tag.oRequest.headers != null))
{
if (search.cbxExamine.SelectedIndex < 2)
{
builder.Append(tag.oRequest.headers.ToString(true, false, true));
}
if ((((search.cbxExamine.SelectedIndex != 1) && (tag.requestBodyBytes != null)) && (tag.requestBodyBytes.Length > 0)) && (search.cbSearchBinaries.Checked || !Utilities.IsBinaryMIME(tag.oRequest["Content-Type"])))
{
if (search.cbSearchDecodeFirst.Checked)
{
tag.utilDecodeRequest();
}
builder.Append(Utilities.getEntityBodyEncoding(tag.oRequest.headers, tag.requestBodyBytes).GetString(tag.requestBodyBytes));
}
}
if (((search.cbxSearchIn.SelectedIndex == 0) || (search.cbxSearchIn.SelectedIndex == 2)) && ((tag.oResponse != null) && (tag.oResponse.headers != null)))
{
if (search.cbxExamine.SelectedIndex != 2)
{
builder.Append(tag.oResponse.headers.ToString(true, false));
}
if ((((search.cbxExamine.SelectedIndex != 1) && (tag.responseBodyBytes != null)) && (tag.responseBodyBytes.Length > 0)) && (search.cbSearchBinaries.Checked || !Utilities.IsBinaryMIME(tag.oResponse["Content-Type"])))
{
if (search.cbSearchDecodeFirst.Checked)
{
tag.utilDecodeResponse();
}
builder.Append(Utilities.getResponseBodyEncoding(tag).GetString(tag.responseBodyBytes));
}
}
if (search.cbxSearchIn.SelectedIndex == 3)
{
builder.Append(tag.fullUrl);
}
string input = builder.ToString();
if (regex != null)
{
success = regex.Match(input).Success;
}
else
{
success = -1 < input.IndexOf(text, search.cbSearchCaseSensitive.Checked ? StringComparison.CurrentCulture : StringComparison.CurrentCultureIgnoreCase);
}
if (success)
{
num ;
if (num == 1)
{
item.EnsureVisible();
}
if (empty != System.Drawing.Color.Empty)
{
if ((tag.oFlags["ui-bold"] != "user-marked") && (item.ForeColor != System.Drawing.Color.Black))
{
tag.oFlags["ui-oldcolor"] = Utilities.GetStringFromColor(item.ForeColor);
}
item.BackColor = empty;
tag.oFlags["ui-backcolor"] = search.cbxSearchColor.Text;
}
if (search.cbSearchSelectMatches.Checked)
{
item.Selected = true;
}
continue;
}
if (search.cbUnmarkOld.Checked && (tag.oFlags["ui-backcolor"] == search.cbxSearchColor.Text))
{
item.BackColor = this.lvSessions.BackColor;
tag.oFlags.Remove("ui-backcolor");
}
}
}
string str3 = "contained";
if (regex != null)
{
str3 = "matched";
}
this.sbpInfo.Text = string.Format("{0} session{1} {2} '{3}'", new object[] { num, (num != 1) ? "s" : string.Empty, str3, (regex == null) ? text : text.Substring(6) });
this.lvSessions.Focus();
}
search.Dispose();
}
好例子网口号:伸出你的我的手 — 分享!
小贴士
感谢您为本站写下的评论,您的评论对其它用户来说具有重要的参考价值,所以请认真填写。
- 类似“顶”、“沙发”之类没有营养的文字,对勤劳贡献的楼主来说是令人沮丧的反馈信息。
- 相信您也不想看到一排文字/表情墙,所以请不要反馈意义不大的重复字符,也请尽量不要纯表情的回复。
- 提问之前请再仔细看一遍楼主的说明,或许是您遗漏了。
- 请勿到处挖坑绊人、招贴广告。既占空间让人厌烦,又没人会搭理,于人于己都无利。
关于好例子网
本站旨在为广大IT学习爱好者提供一个非营利性互相学习交流分享平台。本站所有资源都可以被免费获取学习研究。本站资源来自网友分享,对搜索内容的合法性不具有预见性、识别性、控制性,仅供学习研究,请务必在下载后24小时内给予删除,不得用于其他任何用途,否则后果自负。基于互联网的特殊性,平台无法对用户传输的作品、信息、内容的权属或合法性、安全性、合规性、真实性、科学性、完整权、有效性等进行实质审查;无论平台是否已进行审查,用户均应自行承担因其传输的作品、信息、内容而可能或已经产生的侵权或权属纠纷等法律责任。本站所有资源不代表本站的观点或立场,基于网友分享,根据中国法律《信息网络传播权保护条例》第二十二与二十三条之规定,若资源存在侵权或相关问题请联系本站客服人员,点此联系我们。关于更多版权及免责申明参见 版权及免责申明
网友评论
我要评论