A base class for a simple factory using a ReaderWriterLockSlim. More...
Public Member Functions | |
bool | Add (TKey key, TValue value) |
Adds a kay-value pair. More... | |
bool | Exists (TKey key, out TValue value) |
Gets the value associated with the specified key. More... | |
TValue | Get (TKey key) |
Gets the value associated with the specified key. If the key does not exist in the dictionary a value is loaded with the CreateItem method. More... | |
bool | Remove (TKey key) |
Removes the value with the specified key. More... | |
void | Reset () |
Calls DisposeItem for each item and clears the dictionary. More... | |
void | Dispose () |
Releases all resources used by the current instance. More... | |
Protected Member Functions | |
abstract TValue | CreateItem (TKey key) |
This method creates / loads a value for the key. More... | |
virtual void | Dispose (bool disposing) |
Releases all resources used by the current instance. More... | |
abstract void | DisposeItem (TKey key, TValue value) |
Called when a key-value pair is removed. More... | |
Properties | |
Dictionary< TKey, TValue > | Items [get] |
Gets a reference to the underlying dictionary that contains all existing instances. More... | |
ReaderWriterLockSlim | ReaderWriterLock [get] |
Gets the used ReaderWriterLockSlim. More... | |
A base class for a simple factory using a ReaderWriterLockSlim.
TKey | The type of the key. |
TValue | The type of the value. |
|
inline |
Adds a kay-value pair.
key | The key. |
value | The value. |
|
protectedpure virtual |
This method creates / loads a value for the key.
key | The key. |
|
inline |
Releases all resources used by the current instance.
|
inlineprotectedvirtual |
Releases all resources used by the current instance.
disposing | True if called from Dispose(). |
|
protectedpure virtual |
Called when a key-value pair is removed.
key | The removed key. |
value | The removed value. |
|
inline |
Gets the value associated with the specified key.
key | The key of the value to get. |
value | When this method returns, contains the value associated with the specified key, if the key is found; otherwise, the default value for the type of the value parameter. This parameter is passed uninitialized. |
ArgumentNullException | key is null. |
|
inline |
Gets the value associated with the specified key. If the key does not exist in the dictionary a value is loaded with the CreateItem method.
key | The key of the value to get. |
|
inline |
Removes the value with the specified key.
key | The key of the element to remove. |
|
inline |
Calls DisposeItem for each item and clears the dictionary.
|
getprotected |
|
getprotected |
Gets the used ReaderWriterLockSlim.