Class AggregateDispatcher<TBase>
Calls different action delegates based on the runtime types of objects. Calls multiple delegates when they all match a type (through inheritance).
public class AggregateDispatcher<TBase> where TBase : class
Type Parameters
TBase
The common base type of all objects to be dispatched.
- Inheritance
-
objectAggregateDispatcher<TBase>
- Extension Methods
Methods
Add<TSpecific>(Action<TSpecific>)
Adds a dispatch delegate.
public AggregateDispatcher<TBase> Add<TSpecific>(Action<TSpecific> action) where TSpecific : class, TBase
Parameters
action
Action<TSpecific>The delegate to call.
Returns
- AggregateDispatcher<TBase>
The "this" pointer for use in a "Fluent API" style.
Type Parameters
TSpecific
The specific type to call the delegate for. Matches all subtypes as well.
Dispatch(IEnumerable<TBase>)
Dispatches for each element in a collection. Set up with Add<TSpecific>(Action<TSpecific>) first.
public void Dispatch(IEnumerable<TBase> elements)
Parameters
elements
IEnumerable<TBase>The elements to be dispatched.
Dispatch(TBase)
Dispatches an element to all delegates matching the type. Set up with Add<TSpecific>(Action<TSpecific>) first.
public void Dispatch(TBase element)
Parameters
element
TBaseThe element to be dispatched.
GetEnumerator()
Returns an enumerator that iterates through the collection.
public IEnumerator<Action<TBase>> GetEnumerator()
Returns
- IEnumerator<Action<TBase>>
An enumerator that can be used to iterate through the collection.