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
keystringThe key object
valuestringThe value
Exceptions
- ArgumentException
 The
keyalready 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
keystringThe key to look for.
Returns
- bool
 trueif the key was found.
ContainsValue(string)
Checks whether this collection contains a certain value.
public bool ContainsValue(string value)
  Parameters
valuestringThe value to look for.
Returns
- bool
 trueif the value was found.
GetValue(string)
Returns the value associated to a specific key.
public string GetValue(string key)
  Parameters
keystringThe key to look for.
Returns
- string
 The value associated to
key.
Exceptions
- KeyNotFoundException
 keywas 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
indexintThe zero-based index where the item is to be inserted.
itemXmlDictionaryEntryThe item to insert in the list.
Remove(string)
Removes all values assigned to this key.
public bool Remove(string key)
  Parameters
keystringThe key to look for.
Returns
- bool
 trueif 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.