Class PerTypeDispatcher<TBase>
Calls different action delegates based on the runtime types of objects. Types must be exact matches. Inheritance is not considered.
public class PerTypeDispatcher<TBase> where TBase : class
  Type Parameters
TBaseThe common base type of all objects to be dispatched.
- Inheritance
 - 
      objectPerTypeDispatcher<TBase>
 
- Extension Methods
 
Constructors
PerTypeDispatcher(bool)
Calls different action delegates based on the runtime types of objects. Types must be exact matches. Inheritance is not considered.
public PerTypeDispatcher(bool ignoreMissing)
  Parameters
ignoreMissingbooltrueto silently ignore dispatch attempts on unknown types;falseto throw exceptions.
Methods
Add<TSpecific>(Action<TSpecific>)
Adds a dispatch delegate.
public PerTypeDispatcher<TBase> Add<TSpecific>(Action<TSpecific> action) where TSpecific : TBase
  Parameters
actionAction<TSpecific>The delegate to call.
Returns
- PerTypeDispatcher<TBase>
 The "this" pointer for use in a "Fluent API" style.
Type Parameters
TSpecificThe specific type to call the delegate for. Does not match subtypes
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
elementsIEnumerable<TBase>The elements to be dispatched.
Exceptions
- KeyNotFoundException
 No delegate matching one of the element types was Add<TSpecific>(Action<TSpecific>)ed.
Dispatch(TBase)
Dispatches an element to the delegate matching the type. Set up with Add<TSpecific>(Action<TSpecific>) first.
public void Dispatch(TBase element)
  Parameters
elementTBaseThe element to be dispatched.
Exceptions
- KeyNotFoundException
 No delegate matching the
elementtype was Add<TSpecific>(Action<TSpecific>)ed.
GetEnumerator()
Returns an enumerator that iterates through the collection.
public IEnumerator<KeyValuePair<Type, Action<object>>> GetEnumerator()
  Returns
- IEnumerator<KeyValuePair<Type, Action<object>>>
 An enumerator that can be used to iterate through the collection.