官方版

Importer and Exporter Interfaces

Thread Safety and FiddlerCore

  • Currently, the ISessionImporter and ISessionExporter interfaces are called on the MAIN UI thread. This is almost certain to change in the future, so you should ensure that your classes are thread safe and that they do not attempt to directly manipulate the Fiddler UI.
  • Manipulation of the Fiddler UI is further ill-advised because Fiddler itself may not be loaded; FiddlerCore may be hosting your Importer/Exporter directly. In order to support FiddlerCore, it’s advised that you support the Filename key (with string value of a fully-qualified path) in the dictOptions parameter, and consider supporting a Silent key (value as boolean) as well.

    The ISessionImporter Interface

    Extensions that implement the ISessionImporter interface (which implements the IDisposableinterface) are called when the user uses the File > Import menu option.
    1. public interface ISessionImporter : IDisposable
    2. {
    3. Session[] ImportSessions(string sImportFormat, Dictionary<string, object> dictOptions,
    4. EventHandler<ProgressCallbackEventArgs> evtProgressNotifications);
    5. }
    The method returns an array of Session objects created from the Import of the data.
    The dictOptions dictionary may be null, or may contain a set of string-keyed objects. Most importers support specification of a filename. For example:
    1. dictOptions["Filename"] = "C:\\test.file"

    The ISessionExporter Interface

    This class is defined by Fiddler and allows you to report on the progress of an import or export operation.
    If the completion ratio cannot be determined, simply pass 0 or a “guess” between 0 and 1.0.
    If the Cancel flag is set on the ProgressCallbackEventArgs object after being passed to the evtProgressNotifications callback, import or export should gracefully terminate as soon as possible.
    1. public class ProgressCallbackEventArgs: EventArgs
    2. {
    3. public ProgressCallbackEventArgs(float flCompletionRatio, string sProgressText)
    4. public string ProgressText { get; }
    5. public string PercentComplete { get; }
    6. public bool Cancel { get; set; }
    7. }

谷歌翻译版

导入和导出接口

线程安全和 FiddlerCore

  • 当前,在MAIN UI线程上调用ISessionImporter和ISessionExporter接口。 这在将来几乎肯定会改变,因此您应该确保您的类是线程安全的,并且它们不会试图直接操作Fiddler UI。
  • Fiddler UI的操作更不明智,因为Fiddler本身可能未加载; FiddlerCore可能直接托管您的导入/导出.为了支持FiddlerCore,建议您在dictOptions参数中支持Filename键(具有完全限定路径的字符串值),并考虑也支持Silent键(值为布尔值)。

    ISessionImporter接口

    当用户使用File > Import选项时,将调用实现ISessionImporter接口(实现IDisposableinterface)的扩展。
    1. public interface ISessionImporter : IDisposable
    2. {
    3. Session[] ImportSessions(string sImportFormat, Dictionary<string, object> dictOptions,
    4. EventHandler<ProgressCallbackEventArgs> evtProgressNotifications);
    5. }
    该方法返回从数据导入创建的Session对象的数组。
    dictOptions字典可以为null,或可以包含一组字符串键对象:
    1. dictOptions["Filename"] = "C:\\test.file"

    ISessionExporter接口

    这个类由Fiddler定义,允许您报告导入或导出操作的进度。
    如果无法确定完成率,只需通过0或0到1.0之间的“猜测”即可。
    如果在传递给evtProgressNotifications回调后在ProgressCallbackEventArgs对象上设置了Cancel标志,则导入或导出应尽快终止。
    1. public class ProgressCallbackEventArgs: EventArgs
    2. {
    3. public ProgressCallbackEventArgs(float flCompletionRatio, string sProgressText)
    4. public string ProgressText { get; }
    5. public string PercentComplete { get; }
    6. public bool Cancel { get; set; }
    7. }