Swiss Army Knife
General utility tools for Scada Minds
Public Member Functions | Properties | List of all members
SameValueDictionary< TKey, TValue > Class Template Reference

A stub read-only dictionary that will pretend any key exists in it, and return the default value given in the constructor. More...

Inheritance diagram for SameValueDictionary< TKey, TValue >:

Public Member Functions

 SameValueDictionary (TValue returnedValue)
 Initializes a new instance of the SameValueDictionary<TKey, TValue> class. More...
 
IEnumerator< KeyValuePair< TKey, TValue > > GetEnumerator ()
 Is not implemented - will throw an error if attempting to enumerate over it. More...
 
void Add (KeyValuePair< TKey, TValue > item)
 No-op. More...
 
void Clear ()
 No-op. More...
 
bool Contains (KeyValuePair< TKey, TValue > item)
 Will always return true. More...
 
void CopyTo (KeyValuePair< TKey, TValue >[] array, int arrayIndex)
 Throws an error. Not implemented. SameValueDictionary cannot be enumerated over. More...
 
bool Remove (KeyValuePair< TKey, TValue > item)
 Is a no-op, but returns true. More...
 
void Add (TKey key, TValue value)
 No-op. More...
 
bool ContainsKey (TKey key)
 
bool Remove (TKey key)
 No-op. More...
 
bool TryGetValue (TKey key, out TValue value)
 

Properties

int Count [get]
 Gets how many elements are in this dictionary? Will always pretend to only have one element. More...
 
bool IsReadOnly = true [get]
 
TValue this[TKey key] [get, set]
 Will always return the "returnedValue" set in the constructor. More...
 
ICollection< TKey > Keys [get]
 Gets an error. Not implemented. SameValueDictionary cannot be enumerated over. More...
 
ICollection< TValue > Values [get]
 Gets an error. Not implemented. SameValueDictionary cannot be enumerated over. More...
 

Detailed Description

A stub read-only dictionary that will pretend any key exists in it, and return the default value given in the constructor.

Does not support enumerating over it, or listing keys.

Type Constraints
TKey :notnull 

Constructor & Destructor Documentation

◆ SameValueDictionary()

SameValueDictionary ( TValue  returnedValue)

Initializes a new instance of the SameValueDictionary<TKey, TValue> class.

Parameters
returnedValueThe value that will be returned on each read operation.

Member Function Documentation

◆ Add() [1/2]

void Add ( KeyValuePair< TKey, TValue >  item)
inline

No-op.

◆ Add() [2/2]

void Add ( TKey  key,
TValue  value 
)
inline

No-op.

◆ Clear()

void Clear ( )

No-op.

◆ Contains()

bool Contains ( KeyValuePair< TKey, TValue >  item)

Will always return true.

Returns
True.

◆ ContainsKey()

bool ContainsKey ( TKey  key)

◆ CopyTo()

void CopyTo ( KeyValuePair< TKey, TValue >[]  array,
int  arrayIndex 
)

Throws an error. Not implemented. SameValueDictionary cannot be enumerated over.

◆ GetEnumerator()

IEnumerator<KeyValuePair<TKey, TValue> > GetEnumerator ( )

Is not implemented - will throw an error if attempting to enumerate over it.

Returns
Nothing, it will always throw.

◆ Remove() [1/2]

bool Remove ( KeyValuePair< TKey, TValue >  item)

Is a no-op, but returns true.

Returns
True.

◆ Remove() [2/2]

bool Remove ( TKey  key)

No-op.

◆ TryGetValue()

bool TryGetValue ( TKey  key,
out TValue  value 
)
inline

Property Documentation

◆ Count

int Count
get

Gets how many elements are in this dictionary? Will always pretend to only have one element.

◆ IsReadOnly

bool IsReadOnly = true
get

◆ Keys

ICollection<TKey> Keys
get

Gets an error. Not implemented. SameValueDictionary cannot be enumerated over.

◆ this[TKey key]

TValue this[TKey key]
getset

Will always return the "returnedValue" set in the constructor.

◆ Values

ICollection<TValue> Values
get

Gets an error. Not implemented. SameValueDictionary cannot be enumerated over.


The documentation for this class was generated from the following file: