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
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.
|
Item[String]
Indexer into the Preference collection.
Declaration
public string this[string sPrefName] { get; set; }
Parameters
System. The name of the Preference to update/create or return. |
Property Value
System. 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. Preference branch to monitor, or String.Empty to watch all |
System. The EventHandler accepting PrefChangeEventArgs to notify |
Returns
Preference 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. The Preference name |
System. The default value to return if the specified preference does not exist |
Returns
System. The boolean value of the Preference, or the default value |
Implements
GetEnumerator()
Declaration
public IEnumerator<KeyValuePair<string, string>> GetEnumerator()
Returns
System.
|
GetInt32Pref(String, Int32)
Return an Int32 Preference.
Declaration
public int GetInt32Pref(string sPrefName, int iDefault)
Parameters
System. The Preference name |
System. The default value to return if the specified preference does not exist |
Returns
System. 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[] of preference names |
GetStringPref(String, String)
Gets a preference's value as a string
Declaration
public string GetStringPref(string sPrefName, string sDefault)
Parameters
System. The Preference Name |
System. The default value if the preference is missing |
Returns
System. A string |
Implements
isValidName(String)
Declaration
public static bool isValidName(string sName)
Parameters
System.
|
Returns
System.
|
RemovePref(String)
Delete a Preference from the collection.
Declaration
public void RemovePref(string sPrefName)
Parameters
System. 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
Preference The previously-specified Watcher |
Implements
SetBoolPref(String, Boolean)
Update or create a Boolean preference.
Declaration
public void SetBoolPref(string sPrefName, bool bValue)
Parameters
System. The name of the Preference |
System. 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. The name of the Preference |
System. 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. 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. The name of the Preference |
System. 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. Multi-line string |
ToString(Boolean)
Return a string-based serialization of the Preferences settings.
Declaration
public string ToString(bool bVerbose)
Parameters
System. TRUE for a multi-line format with all preferences |
Returns
System. String |