51Degrees Pipeline .NET  4.1

51Degrees Pipeline for .NET

FiftyOne.Pipeline.Core.TypedMap.TypedKeyMap Class Reference

Detailed Description

A collection that stores data of multiple different types.

Data is accessed using an ITypedKey<T> that specifies the unique 'name' to store the data under and the type of the data being stored.

Inheritance diagram for FiftyOne.Pipeline.Core.TypedMap.TypedKeyMap:

[legend]

Collaboration diagram for FiftyOne.Pipeline.Core.TypedMap.TypedKeyMap:

[legend]

Public Member Functions

 TypedKeyMap ()
Default constructor. More...
 TypedKeyMap (bool threadSafe)
Constructor. More...
void  Add< T > (ITypedKey< T > key, T data)
Add the specified data to the collection using the specified key. More...
T  Get< T > (ITypedKey< T > key)
Get the data associated with the specified key. More...
T  Get< T > ()
Get the data associated with the specified type. More...
ICollection< string >  GetKeys ()
Return string values of the keys in the map. More...
IDictionary< string, object >  AsStringKeyDictionary ()
Return the entire collection as a IDictionary<TKey, TValue> object. More...
bool  TryGetValue< T > (ITypedKey< T > key, out T value)
Check if the map contains an item with the specified key name and type. More...

Constructor & Destructor Documentation

◆ TypedKeyMap() [1/2]

FiftyOne.Pipeline.Core.TypedMap.TypedKeyMap.TypedKeyMap ( )

Default constructor.

Creates a non-thread safe TypedKeyMap

◆ TypedKeyMap() [2/2]

FiftyOne.Pipeline.Core.TypedMap.TypedKeyMap.TypedKeyMap ( bool   threadSafe )

Constructor.

Creates a thread-safe or non-thread safe TypedKeyMap

Parameters
threadSafe - If true then the internal collection is thread-safe. If false then it is not.

Member Function Documentation

◆ Add< T >()

void FiftyOne.Pipeline.Core.TypedMap.TypedKeyMap.Add< T > ( ITypedKey< T >   key,
T   data  
)

Add the specified data to the collection using the specified key.

Template Parameters
T - The type of the data being stored.
Parameters
key - The key used to identify the data.
data - The data to store.

Implements FiftyOne.Pipeline.Core.TypedMap.ITypedKeyMap.

◆ AsStringKeyDictionary()

IDictionary<string, object> FiftyOne.Pipeline.Core.TypedMap.TypedKeyMap.AsStringKeyDictionary ( )

Return the entire collection as a IDictionary<TKey, TValue> object.

Note that this is the actual internal dictionary instance so any changes to it will be reflected in the TypedKeyMap object.

Returns
The data as a IDictionary<TKey, TValue>.

Implements FiftyOne.Pipeline.Core.TypedMap.ITypedKeyMap.

◆ Get< T >() [1/2]

T FiftyOne.Pipeline.Core.TypedMap.TypedKeyMap.Get< T > ( ITypedKey< T >   key )

Get the data associated with the specified key.

If the key is not present or the data value is null then the return value will be default(T).

Template Parameters
T - The type of the data to return.
Parameters
key - The key used to access the data.
Returns
The data.
Exceptions
InvalidCastException - Thrown if the data object stored under the name of the key cannot be cast to the expected type T.
ArgumentNullException - Thrown if the key argument is null
ArgumentException - Thrown if the Name property of the key argument is null
KeyNotFoundException - Thrown if the map does not contain an entry for the key

Implements FiftyOne.Pipeline.Core.TypedMap.ITypedKeyMap.

◆ Get< T >() [2/2]

T FiftyOne.Pipeline.Core.TypedMap.TypedKeyMap.Get< T > ( )

Get the data associated with the specified type.

Template Parameters
T - The type of the data to return.
Returns
The data.

Implements FiftyOne.Pipeline.Core.TypedMap.ITypedKeyMap.

◆ TryGetValue< T >()

bool FiftyOne.Pipeline.Core.TypedMap.TypedKeyMap.TryGetValue< T > ( ITypedKey< T >   key,
out T   value  
)

Check if the map contains an item with the specified key name and type.

If it does exist, retrieve it.

Parameters
key - The key to check for.
value - The value associated with the key.
Returns
True if an entry matching the key exists in the map. False otherwise.

Implements FiftyOne.Pipeline.Core.TypedMap.ITypedKeyMap.