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
Inherited Members
Namespace: Fiddler
Assembly: FiddlerCore.dll
Syntax
public class PreferenceBag : 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
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
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
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
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
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
RemoveWatcher(PreferenceBag.PrefWatcher)
Remove a previously attached Watcher
Declaration
public void RemoveWatcher(PreferenceBag.PrefWatcher wliToRemove)
Parameters
PreferenceBag.PrefWatcher
wliToRemove
The previously-specified Watcher |
Implements
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
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
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
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
ToString()
Return a description of the contents of the preference bag
Declaration
public override string ToString()
Returns
System.String
Multi-line string |
Overrides
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 |