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();
}
评论