Class XmlDictionary
- Namespace
- NanoByte.Common.Collections
- Assembly
- NanoByte.Common.dll
A string dictionary that supports data-binding and can be XML serialized.
[Serializable]
public class XmlDictionary : BindingList<XmlDictionaryEntry>, ICloneable<XmlDictionary>
- Inheritance
-
objectCollection<XmlDictionaryEntry>BindingList<XmlDictionaryEntry>XmlDictionary
- Implements
- Extension Methods
Methods
Add(string, string)
Adds a new value and links it to a key
public void Add(string key, string value)
Parameters
key
stringThe key object
value
stringThe value
Exceptions
- ArgumentException
The
key
already exists in the dictionary.
Clone()
Creates a deep copy of this XmlDictionary (elements are cloned).
public virtual XmlDictionary Clone()
Returns
- XmlDictionary
The cloned XmlDictionary.
ContainsKey(string)
Checks whether this collection contains a certain key.
public bool ContainsKey(string key)
Parameters
key
stringThe key to look for.
Returns
- bool
true
if the key was found.
ContainsValue(string)
Checks whether this collection contains a certain value.
public bool ContainsValue(string value)
Parameters
value
stringThe value to look for.
Returns
- bool
true
if the value was found.
GetValue(string)
Returns the value associated to a specific key.
public string GetValue(string key)
Parameters
key
stringThe key to look for.
Returns
- string
The value associated to
key
.
Exceptions
- KeyNotFoundException
key
was not found in the collection.
InsertItem(int, XmlDictionaryEntry)
Inserts the specified item in the list at the specified index.
protected override void InsertItem(int index, XmlDictionaryEntry item)
Parameters
index
intThe zero-based index where the item is to be inserted.
item
XmlDictionaryEntryThe item to insert in the list.
Remove(string)
Removes all values assigned to this key.
public bool Remove(string key)
Parameters
key
stringThe key to look for.
Returns
- bool
true
if one or more elements were removed; otherwise,false
.
Sort()
Sorts all entries alphabetically by their key.
public void Sort()
ToDictionary()
Convert this XmlDictionary to a System.Collections.Generic.Dictionary<TKey, TValue> for better lookup-performance.
public IDictionary<string, string> ToDictionary()
Returns
- IDictionary<string, string>
A dictionary containing the same data as this collection.