Programming in C#
Top  Previous  Next

The HTTPAnalyzer automation library is packaged as COM components. The .NET COM interop feature makes it easy to utilize COM objects within a .NET application.
If using Visual Studio .NET, a reference may be added to a project via the Project | Add Reference menu selection. The COM tab within the Add Reference window provides access to COM libraries installed on the system. There are three COM components related with HTTPAnalyzer, namely,

HTTPAnalyzer Automation Common Library
The common library which defines most of the automation interfaces. Both Stand-alone and IE add-on editions need the library.
HTTPAnalyzer Stand-alone Automation Library
The stand-alone automation library includes the creatable object, IHTTPAnalyzerStandalone, which controls the HTTPAnalyzer Stand-alone out-proc COM server.
HTTPAnalyzer IE Add-on Library
The IE Add-on automation library includes the creatable object, IHTTPAnalyzerAddon, which controls the HTTPAnalyzer IE Add-on.
HTTPAnalyzer Firefox Add-on Library
The Firefox Add-on automation library includes the creatable object, IHTTPAnalyzerFirefox, which controls the HTTPAnalyzer Firefox Add-on.


In addition, The following namespace are necessary
System.Runtime.InteropServices Includes the COMException class, allowing you to properly handle COM-related exceptions.


Access HTTPAnalyzer Stand-alone automation library.
The IHTTPAnalyzerStandAlone object is used to control the HTTPAnalyzer Stand-alone. You can attach HTTPAnalyzerStandalone into a specific process or user/session/system wide.

using System.Runtime.InteropServices;// Includes the COMException class
using HTTPAnalyzer;//adding a reference to "HTTPAnalyzer Automation Common Library"
using
 HTTPAnalyzerStd;//adding a reference to "HTTPAnalyzer Stand-alone Automation Library"

.......

private void handleOnNewEntryEvent(ILogEntry logEntry, ref bool DiscardIt)
        {
          ;//do something on adding a new log entry
        }
private
 void handleOnUpdateEntryEvent(ILogEntry logEntry)
        {
          ;//do something on updating log entry
        }

IHTTPAnalyzerStandAlone standalone = new HTTPAnalyzerStandAloneClass();
standalone.Visible = true
standalone.AttachProcessByID(Process.GetCurrentProcess().Id)
;

standalone.
OnNewEntry+= handleOnNewEntryEvent;
standalone.OnUpdateEntry += handleOnUpdateEntryEvent;

standalone.Start();

......
standalone.Stop();

foreach (ILogEntry entry in standalone.Log)
{
  Console.WriteLine(entry.URL);
  entry.Request;//get request

  entry.Response;//get response

  entry.Content;//get reqest content.


  // do something

}



Access HTTPAnalyzer IE Add-on automation library.
The IHTTPAnalyzerAddOn object is used to control the HTTPAnalyzer IE Add-on.

using System.Runtime.InteropServices;// Includes the COMException class
using
 HTTPAnalyzer;//adding a reference to "HTTPAnalyzer Automation Common Library"
using
 IEHTTPAnalyzer;//adding a reference to "HTTPAnalyzer IE Add-on Library"
.......
private void handleOnNewEntryEvent(ILogEntry logEntry, ref bool DiscardIt)
        {
          ;//do something on adding a new log entry
        }
private
 void handleOnUpdateEntryEvent(ILogEntry logEntry)
        {
          ;//do something on updating log entry
        }


HTTPAnalyzerAddOnClass addon=new HTTPAnalyzerAddonClass();
addon.start();

addon
.OnNewEntry+= handleOnNewEntryEvent;
addon.OnUpdateEntry += handleOnUpdateEntryEvent;


addon.NavigateAndWait("http://www.ieinspector.com"
, -1);
.........

addon.Stop();

foreach (ILogEntry entry in addon.log)
{
  Console.WriteLine(entry.URL);
  entry.Request;//get request

  entry.Response;//get response

  entry.Content;//get reqest content.


  // do something

}



Access HTTPAnalyzer Firefox Add-on automation library.
The IHTTPAnalyzerFirefox object is used to control the HTTPAnalyzer Firefox Add-on.

using System.Runtime.InteropServices;// Includes the COMException class
using
 HTTPAnalyzer;//adding a reference to "HTTPAnalyzer Automation Common Library"
using
 IEHTTPAnalyzer;//adding a reference to "HTTPAnalyzer Firefox Add-on Library"
.......
private void handleOnNewEntryEvent(ILogEntry logEntry, ref bool DiscardIt)
        {
          ;//do something on adding a new log entry
        }
private
 void handleOnUpdateEntryEvent(ILogEntry logEntry)
        {
          ;//do something on updating log entry
        }


HTTPAnalyzerFirefoxClass addon=new HTTPAnalyzerFirefoxClass();
addon.start();

addon
.OnNewEntry+= handleOnNewEntryEvent;
addon.OnUpdateEntry += handleOnUpdateEntryEvent;


addon.NavigateAndWait("http://www.ieinspector.com"
, -1);
.........

addon.Stop();

foreach (ILogEntry entry in addon.log)
{
  Console.WriteLine(entry.URL);
  entry.Request;//get request

  entry.Response;//get response

  entry.Content;//get reqest content.


  // do something

}