Table of Contents

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
object
XmlDictionary
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

key string

The key object

value string

The 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 string

The 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 string

The 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 string

The key to look for.

Returns

string

The value associated to key.

Exceptions

KeyNotFoundException

key was not found in the collection.

InsertItem(int, XmlDictionaryEntry)

protected override void InsertItem(int index, XmlDictionaryEntry item)

Parameters

index int
item XmlDictionaryEntry

Remove(string)

Removes all values assigned to this key.

public bool Remove(string key)

Parameters

key string

The 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 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.