This class is used to create instances that are unique per key. More...
Public Member Functions | |
UnsynchronizedSingletonFactory (CreateMethodDelegate< TKey, TValue > defaultCreateMethod) | |
Initializes a new instance of the UnsynchronizedSingletonFactory<TKey,TValue> class. More... | |
virtual bool | Add (TKey key, TValue value) |
Adds a new value if there is none for the same key. More... | |
void | ForAll (Action< TValue > action) |
This method iterates over a copy of Instances and executes the action on each item. More... | |
TResult | ForAll< TResult > (Func< TValue, TResult > selector, Func< TResult, TResult, TResult > aggregateFunction, TResult seed) |
This method iterates over a copy of Instances. The selector parameter selects a value of each instance. These values are combined with the aggregateFunction . More... | |
virtual TValue | Get (TKey key, CreateMethodDelegate< TKey, TValue > createMethod) |
Gets an existing value for a key or creates a new one. More... | |
TValue | Get (TKey key) |
Gets an existing value for a key or creates a new one with the default CreateMethod. More... | |
virtual bool | Remove (TKey key) |
Removes a value from the Instances. More... | |
virtual bool | TryGet (TKey key, out TValue value) |
Tries to get an existing value for the key. More... | |
Protected Member Functions | |
virtual void | DoAdd (TKey key, TValue value) |
Adds a value to the Instances. This method is called from Add and Get. More... | |
Properties | |
int | Count [get] |
Gets the number of existing instances. More... | |
CreateMethodDelegate< TKey, TValue > | CreateMethod [get, set] |
Gets or sets the default function that creates new instances. More... | |
Dictionary< TKey, TValue > | Instances [get] |
Gets a reference to the underlying dictionary that contains all existing instances. More... | |
This class is used to create instances that are unique per key.
TKey | The type of key. |
TValue | The type of value. |
Instance members are not thread safe. For multi-threaded environments use the SynchronizedSingletonFactory<TKey, TValue>.
|
inline |
Initializes a new instance of the UnsynchronizedSingletonFactory<TKey,TValue> class.
defaultCreateMethod | The default function that creates new instances. |
|
inlinevirtual |
Adds a new value if there is none for the same key.
key | The key. |
value | The value. |
|
inlineprotectedvirtual |
|
inline |
This method iterates over a copy of Instances and executes the action on each item.
action | The action. |
|
inline |
This method iterates over a copy of Instances. The selector parameter selects a value of each instance. These values are combined with the aggregateFunction .
selector | The action that maps a value to each instance. |
aggregateFunction | The function that combines all selector results. |
seed | The result value to start with. |
TResult | The type of the result value. |
|
inline |
Gets an existing value for a key or creates a new one with the default CreateMethod.
key | The key. |
|
inlinevirtual |
Gets an existing value for a key or creates a new one.
key | The key. |
createMethod | The method that creates a new value if the key has not been added yet. |
|
inlinevirtual |
Removes a value from the Instances.
key | The key. |
|
inlinevirtual |
Tries to get an existing value for the key.
key | The key. |
value | The value. |
|
get |
Gets the number of existing instances.
|
getset |
Gets or sets the default function that creates new instances.
|
getprotected |
Gets a reference to the underlying dictionary that contains all existing instances.