Class XmlDictionary
- Namespace
- NanoByte.Common.Collections
- Assembly
- NanoByte.Common.dll
A string dictionary that supports data-binding and can be XML serialized.
[RequiresUnreferencedCode("Raises ListChanged events with PropertyDescriptors, which may require unreferenced code.")]
[RequiresDynamicCode("XML serialization requires runtime code generation.")]
public class XmlDictionary : BindingList<XmlDictionaryEntry>, IList<XmlDictionaryEntry>, ICollection<XmlDictionaryEntry>, IReadOnlyList<XmlDictionaryEntry>, IReadOnlyCollection<XmlDictionaryEntry>, IEnumerable<XmlDictionaryEntry>, IBindingList, IList, ICollection, IEnumerable, ICancelAddNew, IRaiseItemChangedEvents, ICloneable<XmlDictionary>
- Inheritance
-
objectXmlDictionary
- Implements
- Inherited Members
- Extension Methods
Constructors
XmlDictionary()
public XmlDictionary()
Methods
Add(string, string)
Adds a new value and links it to a key
public void Add(string key, string value)
Parameters
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)
protected override void InsertItem(int index, XmlDictionaryEntry item)
Parameters
indexintitemXmlDictionaryEntry
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 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.