NanoByte.Common  2.9.0
NanoByte.Common.Dispatch.AggregateDispatcher< TBase, TResult > Class Template Reference

Calls different action delegates based on the runtime types of objects. Calls multiple delegates when they all match a type (through inheritance). More...

Inheritance diagram for NanoByte.Common.Dispatch.AggregateDispatcher< TBase, TResult >:

Public Member Functions

AggregateDispatcher< TBase > Add< TSpecific > (Action< TSpecific > action)
 Adds a dispatch delegate. More...
 
void Dispatch (TBase element)
 Dispatches an element to all delegates matching the type. Set up with Add<TSpecific> first. More...
 
void Dispatch ([InstantHandle] IEnumerable< TBase > elements)
 Dispatches for each element in a collection. Set up with Add<TSpecific> first. More...
 
IEnumerator< Action< TBase > > GetEnumerator ()
 
AggregateDispatcher< TBase, TResult > Add< TSpecific > (Func< TSpecific, IEnumerable< TResult >> function)
 Adds a dispatch delegate. More...
 
IEnumerable< TResult > Dispatch (TBase element)
 Dispatches an element to all delegates matching the type. Set up with Add<TSpecific> first. More...
 
IEnumerable< TResult > Dispatch ([InstantHandle] IEnumerable< TBase > elements)
 Dispatches for each element in a collection. Set up with Add<TSpecific> first. More...
 
IEnumerator< Func< TBase, IEnumerable< TResult > > > GetEnumerator ()
 

Detailed Description

Calls different action delegates based on the runtime types of objects. Calls multiple delegates when they all match a type (through inheritance).

Calls different function delegates (with enumerable return values) based on the runtime types of objects. Aggregates results when multiple delegates match a type (through inheritance).

Template Parameters
TBaseThe common base type of all objects to be dispatched.
Template Parameters
TBaseThe common base type of all objects to be dispatched.
TResultThe enumerable return values of the delegates.
Type Constraints
TBase :class 

Member Function Documentation

◆ Add< TSpecific >() [1/2]

AggregateDispatcher<TBase> NanoByte.Common.Dispatch.AggregateDispatcher< TBase, TResult >.Add< TSpecific > ( Action< TSpecific >  action)
inline

Adds a dispatch delegate.

Template Parameters
TSpecificThe specific type to call the delegate for. Matches all subtypes as well.
Parameters
actionThe delegate to call.
Returns
The "this" pointer for use in a "Fluent API" style.
Type Constraints
TSpecific :class 
TSpecific :TBase 

◆ Add< TSpecific >() [2/2]

AggregateDispatcher<TBase, TResult> NanoByte.Common.Dispatch.AggregateDispatcher< TBase, TResult >.Add< TSpecific > ( Func< TSpecific, IEnumerable< TResult >>  function)
inline

Adds a dispatch delegate.

Template Parameters
TSpecificThe specific type to call the delegate for. Matches all subtypes as well.
Parameters
functionThe delegate to call.
Returns
The "this" pointer for use in a "Fluent API" style.
Type Constraints
TSpecific :class 
TSpecific :TBase 

◆ Dispatch() [1/4]

void NanoByte.Common.Dispatch.AggregateDispatcher< TBase, TResult >.Dispatch ( [InstantHandle] IEnumerable< TBase >  elements)
inline

Dispatches for each element in a collection. Set up with Add<TSpecific> first.

Parameters
elementsThe elements to be dispatched.

◆ Dispatch() [2/4]

IEnumerable<TResult> NanoByte.Common.Dispatch.AggregateDispatcher< TBase, TResult >.Dispatch ( [InstantHandle] IEnumerable< TBase >  elements)
inline

Dispatches for each element in a collection. Set up with Add<TSpecific> first.

Parameters
elementsThe elements to be dispatched.
Returns
The values returned by the matching delegates.

◆ Dispatch() [3/4]

void NanoByte.Common.Dispatch.AggregateDispatcher< TBase, TResult >.Dispatch ( TBase  element)
inline

Dispatches an element to all delegates matching the type. Set up with Add<TSpecific> first.

Parameters
elementThe element to be dispatched.

◆ Dispatch() [4/4]

IEnumerable<TResult> NanoByte.Common.Dispatch.AggregateDispatcher< TBase, TResult >.Dispatch ( TBase  element)
inline

Dispatches an element to all delegates matching the type. Set up with Add<TSpecific> first.

Parameters
elementThe element to be dispatched.
Returns
The values returned by all matching delegates aggregated.

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