• Product Bundles

    DevCraft

    All Telerik .NET tools and Kendo UI JavaScript components in one package. Now enhanced with:

    • NEW: Design Kits for Figma
    • Online Training
    • Document Processing Library
    • Embedded Reporting for web and desktop
    Web
    Kendo UI UI for jQuery UI for Angular UI for React UI for Vue UI for ASP.NET AJAX UI for ASP.NET MVC UI for ASP.NET Core UI for Blazor UI for Silverlight UI for PHP UI for JSP
    Mobile
    UI for .NET MAUI UI for Xamarin
    Document Management
    Telerik Document Processing
    Desktop
    UI for .NET MAUI UI for WinUI UI for WinForms UI for WPF UI for UWP
    Reporting & Mocking
    Telerik Reporting Telerik Report Server Telerik JustMock
    Automated Testing
    Test Studio Test Studio Dev Edition
    CMS
    Sitefinity
    UI/UX Design
    Unite UX
    Debugging
    Fiddler Fiddler Everywhere Fiddler Classic Fiddler Jam FiddlerCap FiddlerCore
    Extended Reality
    UI for Unity XR
    Free Tools
    JustAssembly JustDecompile VB.NET to C# Converter Testing Framework
    View all products
  • Overview
    • jQuery
    • Angular
    • React
    • Vue
  • Demos
    • What's New
    • Roadmap
    • Release History
  • Docs & Support
  • Pricing
  • Search
  • Shopping cart
    • Account Overview
    • Your Licenses
    • Support Center
    • Forum Profile
    • Payment Methods
    • Edit Profile
    • Log out
  • Login
  • Contact Us
  • Try now

Class PreferenceBag

The PreferenceBag is used to maintain a threadsafe Key/Value list of preferences, persisted in the registry, and with appropriate eventing when a value changes.

Inheritance
System.Object
PreferenceBag
Namespace: Fiddler
Assembly: FiddlerCore.dll

Syntax

public class PreferenceBag : Object, IFiddlerPreferences, IEnumerable<KeyValuePair<string, string>>, IEnumerable

Properties

CurrentProfile

Returns a string naming the current profile

Declaration
public string CurrentProfile { get; }
Property Value
System.String

Item[String]

Indexer into the Preference collection.

Declaration
public string this[string sPrefName] { get; set; }
Parameters
System.String sPrefName

The name of the Preference to update/create or return.

Property Value
System.String

The string value of the preference, or null.

Implements
IFiddlerPreferences.Item[String]

Methods

AddWatcher(String, EventHandler<PrefChangeEventArgs>)

Add a watcher for changes to the specified preference or preference branch.

Declaration
public PreferenceBag.PrefWatcher AddWatcher(string sPrefixFilter, EventHandler<PrefChangeEventArgs> pcehHandler)
Parameters
System.String sPrefixFilter

Preference branch to monitor, or String.Empty to watch all

System.EventHandler<PrefChangeEventArgs> pcehHandler

The EventHandler accepting PrefChangeEventArgs to notify

Returns
PreferenceBag.PrefWatcher

Returns the PrefWatcher object which has been added, store to pass to RemoveWatcher later.

Implements
IFiddlerPreferences.AddWatcher(String, EventHandler<PrefChangeEventArgs>)

Close()

Remove all watchers and write the registry.

Declaration
public void Close()

GetBoolPref(String, Boolean)

Return a bool preference.

Declaration
public bool GetBoolPref(string sPrefName, bool bDefault)
Parameters
System.String sPrefName

The Preference name

System.Boolean bDefault

The default value to return if the specified preference does not exist

Returns
System.Boolean

The boolean value of the Preference, or the default value

Implements
IFiddlerPreferences.GetBoolPref(String, Boolean)

GetEnumerator()

Declaration
public IEnumerator<KeyValuePair<string, string>> GetEnumerator()
Returns
System.Collections.Generic.IEnumerator<System.Collections.Generic.KeyValuePair<System.String, System.String>>

GetInt32Pref(String, Int32)

Return an Int32 Preference.

Declaration
public int GetInt32Pref(string sPrefName, int iDefault)
Parameters
System.String sPrefName

The Preference name

System.Int32 iDefault

The default value to return if the specified preference does not exist

Returns
System.Int32

The Int32 value of the Preference, or the default value

Implements
IFiddlerPreferences.GetInt32Pref(String, Int32)

GetPrefArray()

Get a string array of the preference names

Declaration
public string[] GetPrefArray()
Returns
System.String[]

string[] of preference names

GetStringPref(String, String)

Gets a preference's value as a string

Declaration
public string GetStringPref(string sPrefName, string sDefault)
Parameters
System.String sPrefName

The Preference Name

System.String sDefault

The default value if the preference is missing

Returns
System.String

A string

Implements
IFiddlerPreferences.GetStringPref(String, String)

isValidName(String)

Declaration
public static bool isValidName(string sName)
Parameters
System.String sName

Returns
System.Boolean

RemovePref(String)

Delete a Preference from the collection.

Declaration
public void RemovePref(string sPrefName)
Parameters
System.String sPrefName

The name of the Preference to be removed.

Implements
IFiddlerPreferences.RemovePref(String)

RemoveWatcher(PreferenceBag.PrefWatcher)

Remove a previously attached Watcher

Declaration
public void RemoveWatcher(PreferenceBag.PrefWatcher wliToRemove)
Parameters
PreferenceBag.PrefWatcher wliToRemove

The previously-specified Watcher

Implements
IFiddlerPreferences.RemoveWatcher(PreferenceBag.PrefWatcher)

SetBoolPref(String, Boolean)

Update or create a Boolean preference.

Declaration
public void SetBoolPref(string sPrefName, bool bValue)
Parameters
System.String sPrefName

The name of the Preference

System.Boolean bValue

The value to assign to the Preference

Implements
IFiddlerPreferences.SetBoolPref(String, Boolean)

SetInt32Pref(String, Int32)

Update or create a Int32 Preference

Declaration
public void SetInt32Pref(string sPrefName, int iValue)
Parameters
System.String sPrefName

The name of the Preference

System.Int32 iValue

The value to assign to the Preference

Implements
IFiddlerPreferences.SetInt32Pref(String, Int32)

SetPrefs(IEnumerable<KeyValuePair<String, String>>)

Update or create multiple preferences.

Declaration
public void SetPrefs(IEnumerable<KeyValuePair<string, string>> prefs)
Parameters
System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<System.String, System.String>> prefs

An enumeration of the preferences' names and values to store.

Implements
IFiddlerPreferences.SetPrefs(IEnumerable<KeyValuePair<String, String>>)

SetStringPref(String, String)

Update or create a string preference.

Declaration
public void SetStringPref(string sPrefName, string sValue)
Parameters
System.String sPrefName

The name of the Preference

System.String sValue

The value to assign to the Preference

Implements
IFiddlerPreferences.SetStringPref(String, String)

ToString()

Return a description of the contents of the preference bag

Declaration
public override string ToString()
Returns
System.String

Multi-line string

ToString(Boolean)

Return a string-based serialization of the Preferences settings.

Declaration
public string ToString(bool bVerbose)
Parameters
System.Boolean bVerbose

TRUE for a multi-line format with all preferences

Returns
System.String

String

Getting Started
  • Try Now
Community
  • Forums
  • Blogs
  • Feedback Portal

Copyright © 2019 Progress Software Corporation and/or its subsidiaries or affiliates.
All Rights Reserved.

Progress, Telerik, and certain product names used herein are trademarks or registered trademarks of Progress Software Corporation and/or one of its subsidiaries or affiliates in the U.S. and/or other countries. See Trademarks for appropriate markings.