I've made a method which interacts with Fiddler in C#. The code looks like this:
using Fiddler;
namespace SmartMocks
{
public class SmartMocks
{
public static void SmartMock(Session oSession, string directoryPath)
{ //etc...
import SmartMocks;
And then I can call the function in FiddlerScript like this:
SmartMocks.SmartMocks.SmartMock(oSession, "C:\\SomeFile.txt");
This works fine. However, I'd like to make SmartMock be an extension method of Fiddler.Session, so that I can use this nicer-looking syntax instead in FiddlerScript:
oSession.SmartMock("C:\\SomeFile.txt");
I'm not familiar with JScript.NET and how it handles references, so I've been having trouble adding this method to Fiddler.Session. I tried changing the code to an extension like this:
namespace SmartMocks
{
public static class SmartMocks
{
public static void SmartMock(this Session oSession, string directoryPath)
{
However, when compiling FiddlerScript, calling "oSession.SmartMock("C:\\SomeFile.txt")" gives the error "Objects of type 'Fiddler.Session' do not have such a member".
My question is:
- How do you create an extension method to a class (like Fiddler.Session) in JScript.NET?