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.

Definition

Namespace:Fiddler

Assembly:FiddlerCore.dll

Syntax:

cs-api-definition
public class PreferenceBag : IFiddlerPreferences, IEnumerable<KeyValuePair<string, string>>, IEnumerable

Inheritance: objectPreferenceBag

Implements: IEnumerableIEnumerable<KeyValuePair<string, string>>IFiddlerPreferences

Inherited Members object.GetType()object.MemberwiseClone()object.Equals(object)object.Equals(object, object)object.ReferenceEquals(object, object)object.GetHashCode()

Properties

CurrentProfile

Returns a string naming the current profile

Declaration

cs-api-definition
public string CurrentProfile { get; }

Property Value

string

this[string]

Indexer into the Preference collection.

Declaration

cs-api-definition
public string this[string sPrefName] { get; set; }

Parameters

sPrefName

string

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

Property Value

string

The string value of the preference, or null.

Implements IFiddlerPreferences.this[string]

Methods

AddWatcher(string, EventHandler<PrefChangeEventArgs>)

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

Declaration

cs-api-definition
public PreferenceBag.PrefWatcher AddWatcher(string sPrefixFilter, EventHandler<PrefChangeEventArgs> pcehHandler)

Parameters

sPrefixFilter

string

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

pcehHandler

EventHandler<PrefChangeEventArgs>

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

cs-api-definition
public void Close()

GetBoolPref(string, bool)

Return a bool preference.

Declaration

cs-api-definition
public bool GetBoolPref(string sPrefName, bool bDefault)

Parameters

sPrefName

string

The Preference name

bDefault

bool

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

Returns

bool

The boolean value of the Preference, or the default value

Implements IFiddlerPreferences.GetBoolPref(string, bool)

GetEnumerator()

Declaration

cs-api-definition
public IEnumerator<KeyValuePair<string, string>> GetEnumerator()

Returns

IEnumerator<KeyValuePair<string, string>>

Implements IEnumerable<KeyValuePair<string, string>>.GetEnumerator()

GetInt32Pref(string, int)

Return an Int32 Preference.

Declaration

cs-api-definition
public int GetInt32Pref(string sPrefName, int iDefault)

Parameters

sPrefName

string

The Preference name

iDefault

int

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

Returns

int

The Int32 value of the Preference, or the default value

Implements IFiddlerPreferences.GetInt32Pref(string, int)

GetPrefArray()

Get a string array of the preference names

Declaration

cs-api-definition
public string[] GetPrefArray()

Returns

string[]

string[] of preference names

GetStringPref(string, string)

Gets a preference's value as a string

Declaration

cs-api-definition
public string GetStringPref(string sPrefName, string sDefault)

Parameters

sPrefName

string

The Preference Name

sDefault

string

The default value if the preference is missing

Returns

string

A string

Implements IFiddlerPreferences.GetStringPref(string, string)

RemovePref(string)

Delete a Preference from the collection.

Declaration

cs-api-definition
public void RemovePref(string sPrefName)

Parameters

sPrefName

string

The name of the Preference to be removed.

Implements IFiddlerPreferences.RemovePref(string)

RemoveWatcher(PrefWatcher)

Remove a previously attached Watcher

Declaration

cs-api-definition
public void RemoveWatcher(PreferenceBag.PrefWatcher wliToRemove)

Parameters

wliToRemove

PreferenceBag.PrefWatcher

The previously-specified Watcher

Implements IFiddlerPreferences.RemoveWatcher(PreferenceBag.PrefWatcher)

SetBoolPref(string, bool)

Update or create a Boolean preference.

Declaration

cs-api-definition
public void SetBoolPref(string sPrefName, bool bValue)

Parameters

sPrefName

string

The name of the Preference

bValue

bool

The value to assign to the Preference

Implements IFiddlerPreferences.SetBoolPref(string, bool)

SetInt32Pref(string, int)

Update or create a Int32 Preference

Declaration

cs-api-definition
public void SetInt32Pref(string sPrefName, int iValue)

Parameters

sPrefName

string

The name of the Preference

iValue

int

The value to assign to the Preference

Implements IFiddlerPreferences.SetInt32Pref(string, int)

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

Update or create multiple preferences.

Declaration

cs-api-definition
public void SetPrefs(IEnumerable<KeyValuePair<string, string>> prefs)

Parameters

prefs

IEnumerable<KeyValuePair<string, string>>

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

cs-api-definition
public void SetStringPref(string sPrefName, string sValue)

Parameters

sPrefName

string

The name of the Preference

sValue

string

The value to assign to the Preference

Implements IFiddlerPreferences.SetStringPref(string, string)

ToString()

Return a description of the contents of the preference bag

Declaration

cs-api-definition
public override string ToString()

Returns

string

Multi-line string

Overrides object.ToString()

ToString(bool)

Return a string-based serialization of the Preferences settings.

Declaration

cs-api-definition
public string ToString(bool bVerbose)

Parameters

bVerbose

bool

TRUE for a multi-line format with all preferences

Returns

string

String

isValidName(string)

Declaration

cs-api-definition
public static bool isValidName(string sName)

Parameters

sName

string

Returns

bool