NanoByte.Common
2.6.1
|
Calls different action delegates based on the runtime types of objects. Types must be exact matches. Inheritance is not considered. More...
Public Member Functions | |
PerTypeDispatcher (bool ignoreMissing) | |
Creates a new dispatcher. More... | |
PerTypeDispatcher< TBase > | Add< TSpecific > (Action< TSpecific > action) |
Adds a dispatch delegate. More... | |
void | Dispatch (TBase element) |
Dispatches an element to the delegate matching the type. Set up with Add<TSpecific> first. More... | |
void | Dispatch (IEnumerable< TBase > elements) |
Dispatches for each element in a collection. Set up with Add<TSpecific> first. More... | |
IEnumerator< KeyValuePair< Type, Action< object > > > | GetEnumerator () |
PerTypeDispatcher< TBase, TResult > | Add< TSpecific > (Func< TSpecific, TResult > function) |
Adds a dispatch delegate. More... | |
TResult | Dispatch (TBase element) |
Dispatches an element to the delegate matching the type. Set up with Add<TSpecific> first. More... | |
IEnumerable< TResult > | Dispatch (IEnumerable< TBase > elements) |
Dispatches for each element in a collection. Set up with Add<TSpecific> first. More... | |
IEnumerator< KeyValuePair< Type, Func< TBase, TResult > > > | GetEnumerator () |
Calls different action delegates based on the runtime types of objects. Types must be exact matches. Inheritance is not considered.
Calls different function delegates (with return values) based on the runtime types of objects. Types must be exact matches. Inheritance is not considered.
TBase | The common base type of all objects to be dispatched. |
TBase | The common base type of all objects to be dispatched. |
TResult | The return value of the delegates. |
TBase | : | class |
|
inline |
Creates a new dispatcher.
ignoreMissing | true to silently ignore dispatch attempts on unknown types; false to throw exceptions. |
|
inline |
Adds a dispatch delegate.
TSpecific | The specific type to call the delegate for. Does not match subtypes |
action | The delegate to call. |
TSpecific | : | TBase |
|
inline |
Adds a dispatch delegate.
TSpecific | The specific type to call the delegate for. Does not match subtypes. |
function | The delegate to call. |
TSpecific | : | TBase |
|
inline |
Dispatches for each element in a collection. Set up with Add<TSpecific> first.
elements | The elements to be dispatched. |
KeyNotFoundException | No delegate matching one of the element types was Add<TSpecific>ed and _ignoreMissing is false . |
|
inline |
Dispatches for each element in a collection. Set up with Add<TSpecific> first.
elements | The elements to be dispatched. |
KeyNotFoundException | No delegate matching one of the element types was Add<TSpecific>ed. |
|
inline |
Dispatches an element to the delegate matching the type. Set up with Add<TSpecific> first.
element | The element to be dispatched. |
KeyNotFoundException | No delegate matching the element type was Add<TSpecific>ed and _ignoreMissing is false . |
|
inline |
Dispatches an element to the delegate matching the type. Set up with Add<TSpecific> first.
element | The element to be dispatched. |
KeyNotFoundException | No delegate matching the element type was Add<TSpecific>ed. |