Table of Contents

Class EmptyDictionary

Namespace
log4net.Util
Assembly
log4net.dll

An always empty IDictionary.

public sealed class EmptyDictionary : IDictionary, ICollection, IEnumerable
Inheritance
EmptyDictionary
Implements
Inherited Members

Remarks

A singleton implementation of the IDictionary interface that always represents an empty collection.

Properties

Count

Gets the number of elements contained in the ICollection

public int Count { get; }

Property Value

int

The number of elements contained in the ICollection.

Remarks

As the collection is empty the Count is always 0.

Instance

Gets the singleton instance of the EmptyDictionary.

public static EmptyDictionary Instance { get; }

Property Value

EmptyDictionary

The singleton instance of the EmptyDictionary.

Remarks

Gets the singleton instance of the EmptyDictionary.

IsFixedSize

Gets a value indicating whether the EmptyDictionary has a fixed size.

public bool IsFixedSize { get; }

Property Value

bool

true

Remarks

As the collection is empty IsFixedSize always returns true.

IsReadOnly

Gets a value indicating whether the EmptyDictionary is read-only.

public bool IsReadOnly { get; }

Property Value

bool

true

Remarks

As the collection is empty IsReadOnly always returns true.

IsSynchronized

Gets a value indicating if access to the ICollection is synchronized (thread-safe).

public bool IsSynchronized { get; }

Property Value

bool

true if access to the ICollection is synchronized (thread-safe); otherwise, false.

Remarks

For the EmptyCollection this property is always true.

this[object]

Gets or sets the element with the specified key.

public object this[object key] { get; set; }

Parameters

key object

The key of the element to get or set.

Property Value

object

null

Remarks

As the collection is empty no values can be looked up or stored. If the index getter is called then null is returned. A InvalidOperationException is thrown if the setter is called.

Exceptions

InvalidOperationException

This dictionary is always empty and cannot be modified.

Keys

Gets an ICollection containing the keys of the EmptyDictionary.

public ICollection Keys { get; }

Property Value

ICollection

An ICollection containing the keys of the EmptyDictionary.

Remarks

As the collection is empty a EmptyCollection is returned.

SyncRoot

Gets an object that can be used to synchronize access to the ICollection.

public object SyncRoot { get; }

Property Value

object

An object that can be used to synchronize access to the ICollection.

Remarks

As the collection is empty and thread safe and synchronized this instance is also the SyncRoot object.

Values

Gets an ICollection containing the values of the EmptyDictionary.

public ICollection Values { get; }

Property Value

ICollection

An ICollection containing the values of the EmptyDictionary.

Remarks

As the collection is empty a EmptyCollection is returned.

Methods

Add(object, object)

Adds an element with the provided key and value to the EmptyDictionary.

public void Add(object key, object value)

Parameters

key object

The object to use as the key of the element to add.

value object

The object to use as the value of the element to add.

Remarks

As the collection is empty no new values can be added. A InvalidOperationException is thrown if this method is called.

Exceptions

InvalidOperationException

This dictionary is always empty and cannot be modified.

Clear()

Removes all elements from the EmptyDictionary.

public void Clear()

Remarks

As the collection is empty no values can be removed. A InvalidOperationException is thrown if this method is called.

Exceptions

InvalidOperationException

This dictionary is always empty and cannot be modified.

Contains(object)

Determines whether the EmptyDictionary contains an element with the specified key.

public bool Contains(object key)

Parameters

key object

The key to locate in the EmptyDictionary.

Returns

bool

false

Remarks

As the collection is empty the Contains(object) method always returns false.

CopyTo(Array, int)

Copies the elements of the ICollection to an Array, starting at a particular Array index.

public void CopyTo(Array array, int index)

Parameters

array Array

The one-dimensional Array that is the destination of the elements copied from ICollection. The Array must have zero-based indexing.

index int

The zero-based index in array at which copying begins.

Remarks

As the collection is empty no values are copied into the array.

GetEnumerator()

Returns an enumerator that can iterate through a collection.

public IDictionaryEnumerator GetEnumerator()

Returns

IDictionaryEnumerator

An IEnumerator that can be used to iterate through the collection.

Remarks

As the collection is empty a NullEnumerator is returned.

Remove(object)

Removes the element with the specified key from the EmptyDictionary.

public void Remove(object key)

Parameters

key object

The key of the element to remove.

Remarks

As the collection is empty no values can be removed. A InvalidOperationException is thrown if this method is called.

Exceptions

InvalidOperationException

This dictionary is always empty and cannot be modified.