Class EventDispatcher
The EventDispatcher is responsible for dispatching and invoking all the registered IEventHandler methods
Inheritance
Namespace: OpenAPI.Events
Assembly: OpenAPI.dll
Syntax
public class EventDispatcher : object
Constructors
| Improve this Doc View SourceEventDispatcher(OpenApi, EventDispatcher[])
Declaration
public EventDispatcher(OpenApi openApi, params EventDispatcher[] dispatchers)
Parameters
| Type | Name | Description |
|---|---|---|
| OpenApi | openApi | |
| EventDispatcher[] | dispatchers |
Properties
| Improve this Doc View SourceApi
Declaration
protected OpenApi Api { get; }
Property Value
| Type | Description |
|---|---|
| OpenApi |
Methods
| Improve this Doc View SourceDispatchEvent(Event)
Dispatches a new Event to all methods registered with an EventHandlerAttribute
Declaration
public void DispatchEvent(Event e)
Parameters
| Type | Name | Description |
|---|---|---|
| Event | e | The event to dispatch |
DispatchEventAsync<TEvent>(TEvent)
Dispatches
Declaration
public Task<TEvent> DispatchEventAsync<TEvent>(TEvent e)
where TEvent : Event
Parameters
| Type | Name | Description |
|---|---|---|
| TEvent | e |
Returns
| Type | Description |
|---|---|
| Task<TEvent> |
Type Parameters
| Name | Description |
|---|---|
| TEvent |
LoadFrom(Assembly)
Loads all types implementing the Event class
Declaration
public void LoadFrom(Assembly assembly)
Parameters
| Type | Name | Description |
|---|---|---|
| Assembly | assembly | The assembly containing the Event implementations |
RegisterEvents(IEventHandler)
Registers all EventHandler methods with the current EventDispatcher.
Declaration
public void RegisterEvents(IEventHandler obj)
Parameters
| Type | Name | Description |
|---|---|---|
| IEventHandler | obj | The class to scan for EventHandlers |
RegisterEventType(Type)
Registers a new Event
Declaration
public bool RegisterEventType(Type type)
Parameters
| Type | Name | Description |
|---|---|---|
| Type | type | The type of the Event to register |
Returns
| Type | Description |
|---|---|
| System.Boolean | Whether the event was succesfully registered. |
RegisterEventType<TEvent>()
Registers a new Event type with the current EventDispatcher
Declaration
public void RegisterEventType<TEvent>()
where TEvent : Event
Type Parameters
| Name | Description |
|---|---|
| TEvent | The type of the Event to register |
Exceptions
| Type | Condition |
|---|---|
| DuplicateTypeException | Thrown when the type of |
Unload(Assembly)
Unloads all Event's that were registered by specified assembly
Declaration
public void Unload(Assembly assembly)
Parameters
| Type | Name | Description |
|---|---|---|
| Assembly | assembly | The assembly containing the types to be unloaded. |
UnregisterEvents(IEventHandler)
Unregisters all EventHandlerAttribute from the specified IEventHandler implementation from the current EventDispatcher After UnRegistering, the class will no longer get invoked when an event gets dispatched.
Declaration
public void UnregisterEvents(IEventHandler obj)
Parameters
| Type | Name | Description |
|---|---|---|
| IEventHandler | obj | The implementation to unregister the eventhandlers for |