Interface IEventAggregator
Allows listening to events without introducing direct coupling between observer and observable. The observer can handle events withou introducing a dependency to the event source.
Namespace: BionicCode.Utilities.Net
Assembly: BionicCode.Utilities.Net.Common.dll
Syntax
public interface IEventAggregator
Methods
| Improve this Doc View SourceTryRegisterGlobalObserver(Delegate)
Registers a handler for any registered event source with a compatible event delegate signature.
Declaration
bool TryRegisterGlobalObserver(Delegate eventHandler)
Parameters
| Type | Name | Description |
|---|---|---|
| Delegate | eventHandler | A delegate that handles the specified event. |
Returns
| Type | Description |
|---|---|
| Boolean |
|
TryRegisterGlobalObserver(Delegate, Boolean)
Registers a handler for any registered event source with a compatible event delegate signature.
Declaration
bool TryRegisterGlobalObserver(Delegate eventHandler, bool isMarshalEventToCurrentThreadEnabled)
Parameters
| Type | Name | Description |
|---|---|---|
| Delegate | eventHandler | A delegate that handles the specified event. |
| Boolean | isMarshalEventToCurrentThreadEnabled |
|
Returns
| Type | Description |
|---|---|
| Boolean |
|
TryRegisterGlobalObserver(Delegate, SynchronizationContext)
Registers a handler for any registered event source with a compatible event delegate signature.
Declaration
bool TryRegisterGlobalObserver(Delegate eventHandler, SynchronizationContext synchronizationContext)
Parameters
| Type | Name | Description |
|---|---|---|
| Delegate | eventHandler | A delegate that handles the specified event. |
| SynchronizationContext | synchronizationContext | The SynchronizationContext that the event delegate is to be executed on. |
Returns
| Type | Description |
|---|---|
| Boolean |
|
TryRegisterGlobalObserver(String, Delegate)
Register an event delegate to handle a specific event which could be published by any type.
Declaration
bool TryRegisterGlobalObserver(string eventName, Delegate eventHandler)
Parameters
| Type | Name | Description |
|---|---|---|
| String | eventName | The name of the observed event. |
| Delegate | eventHandler | A delegate that handles the specified event. |
Returns
| Type | Description |
|---|---|
| Boolean |
|
TryRegisterGlobalObserver(String, Delegate, Boolean)
Register an event delegate to handle a specific event which could be published by any type.
Declaration
bool TryRegisterGlobalObserver(string eventName, Delegate eventHandler, bool isMarshalEventToCurrentThreadEnabled)
Parameters
| Type | Name | Description |
|---|---|---|
| String | eventName | The name of the observed event. |
| Delegate | eventHandler | A delegate that handles the specified event. |
| Boolean | isMarshalEventToCurrentThreadEnabled |
|
Returns
| Type | Description |
|---|---|
| Boolean |
|
TryRegisterGlobalObserver(String, Delegate, SynchronizationContext)
Register an event delegate to handle a specific event which could be published by any type.
Declaration
bool TryRegisterGlobalObserver(string eventName, Delegate eventHandler, SynchronizationContext synchronizationContext)
Parameters
| Type | Name | Description |
|---|---|---|
| String | eventName | The name of the observed event. |
| Delegate | eventHandler | A delegate that handles the specified event. |
| SynchronizationContext | synchronizationContext | The SynchronizationContext that the event delegate is to be executed on. |
Returns
| Type | Description |
|---|---|
| Boolean |
|
TryRegisterGlobalObserver<TEventArgs>(EventHandler<TEventArgs>)
Registers a handler for any registered event source with a compatible event delegate signature.
Declaration
bool TryRegisterGlobalObserver<TEventArgs>(EventHandler<TEventArgs> eventHandler)
Parameters
| Type | Name | Description |
|---|---|---|
| EventHandler<TEventArgs> | eventHandler | A delegate that handles the specified event. |
Returns
| Type | Description |
|---|---|
| Boolean |
|
Type Parameters
| Name | Description |
|---|---|
| TEventArgs | The type of the event args object. |
TryRegisterGlobalObserver<TEventArgs>(EventHandler<TEventArgs>, Boolean)
Registers a handler for any registered event source with a compatible event delegate signature.
Declaration
bool TryRegisterGlobalObserver<TEventArgs>(EventHandler<TEventArgs> eventHandler, bool isMarshalEventToCurrentThreadEnabled)
Parameters
| Type | Name | Description |
|---|---|---|
| EventHandler<TEventArgs> | eventHandler | A delegate that handles the specified event. |
| Boolean | isMarshalEventToCurrentThreadEnabled |
|
Returns
| Type | Description |
|---|---|
| Boolean |
|
Type Parameters
| Name | Description |
|---|---|
| TEventArgs | The type of the event args object. |
TryRegisterGlobalObserver<TEventArgs>(EventHandler<TEventArgs>, SynchronizationContext)
Registers a handler for any registered event source with a compatible event delegate signature.
Declaration
bool TryRegisterGlobalObserver<TEventArgs>(EventHandler<TEventArgs> eventHandler, SynchronizationContext synchronizationContext)
Parameters
| Type | Name | Description |
|---|---|---|
| EventHandler<TEventArgs> | eventHandler | A delegate that handles the specified event. |
| SynchronizationContext | synchronizationContext | The SynchronizationContext that the event delegate is to be executed on. |
Returns
| Type | Description |
|---|---|
| Boolean |
|
Type Parameters
| Name | Description |
|---|---|
| TEventArgs | The type of the event args object. |
TryRegisterGlobalObserver<TEventArgs>(String, EventHandler<TEventArgs>)
Register an event delegate to handle a specific event which could be published by any type.
Declaration
bool TryRegisterGlobalObserver<TEventArgs>(string eventName, EventHandler<TEventArgs> eventHandler)
Parameters
| Type | Name | Description |
|---|---|---|
| String | eventName | The name of the observed event. |
| EventHandler<TEventArgs> | eventHandler | A delegate that handles the specified event. |
Returns
| Type | Description |
|---|---|
| Boolean |
|
Type Parameters
| Name | Description |
|---|---|
| TEventArgs | The type of the event args object. |
TryRegisterGlobalObserver<TEventArgs>(String, EventHandler<TEventArgs>, Boolean)
Register an event delegate to handle a specific event which could be published by any type.
Declaration
bool TryRegisterGlobalObserver<TEventArgs>(string eventName, EventHandler<TEventArgs> eventHandler, bool isMarshalEventToCurrentThreadEnabled)
Parameters
| Type | Name | Description |
|---|---|---|
| String | eventName | The name of the observed event. |
| EventHandler<TEventArgs> | eventHandler | A delegate that handles the specified event. |
| Boolean | isMarshalEventToCurrentThreadEnabled |
|
Returns
| Type | Description |
|---|---|
| Boolean |
|
Type Parameters
| Name | Description |
|---|---|
| TEventArgs | The type of the event args object. |
TryRegisterGlobalObserver<TEventArgs>(String, EventHandler<TEventArgs>, SynchronizationContext)
Register an event delegate to handle a specific event which could be published by any type.
Declaration
bool TryRegisterGlobalObserver<TEventArgs>(string eventName, EventHandler<TEventArgs> eventHandler, SynchronizationContext synchronizationContext)
Parameters
| Type | Name | Description |
|---|---|---|
| String | eventName | The name of the observed event. |
| EventHandler<TEventArgs> | eventHandler | A delegate that handles the specified event. |
| SynchronizationContext | synchronizationContext | The SynchronizationContext that the event delegate is to be executed on. |
Returns
| Type | Description |
|---|---|
| Boolean |
|
Type Parameters
| Name | Description |
|---|---|
| TEventArgs | The type of the event args object. |
TryRegisterObservable(Object, IEnumerable<String>)
Register a type as event source.
Declaration
bool TryRegisterObservable(object eventSource, IEnumerable<string> eventNames)
Parameters
| Type | Name | Description |
|---|---|---|
| Object | eventSource | The publisher instance. |
| IEnumerable<String> | eventNames | A collection of event names that define the observed events of the |
Returns
| Type | Description |
|---|---|
| Boolean |
|
TryRegisterObserver(String, Type, Delegate)
Registers an event delegate to handle a specific event published by a specific observable type.
Declaration
bool TryRegisterObserver(string eventName, Type eventSourceType, Delegate eventHandler)
Parameters
| Type | Name | Description |
|---|---|---|
| String | eventName | The name of the observed event. |
| Type | eventSourceType | The type of the observable. |
| Delegate | eventHandler | A delegate that handles the specified event. |
Returns
| Type | Description |
|---|---|
| Boolean |
|
TryRegisterObserver(String, Type, Delegate, Boolean)
Registers an event delegate to handle a specific event published by a specific observable type.
Declaration
bool TryRegisterObserver(string eventName, Type eventSourceType, Delegate eventHandler, bool isMarshalEventToCurrentThreadEnabled)
Parameters
| Type | Name | Description |
|---|---|---|
| String | eventName | The name of the observed event. |
| Type | eventSourceType | The type of the observable. |
| Delegate | eventHandler | A delegate that handles the specified event. |
| Boolean | isMarshalEventToCurrentThreadEnabled |
|
Returns
| Type | Description |
|---|---|
| Boolean |
|
TryRegisterObserver(String, Type, Delegate, SynchronizationContext)
Registers an event delegate to handle a specific event published by a specific observable type.
Declaration
bool TryRegisterObserver(string eventName, Type eventSourceType, Delegate eventHandler, SynchronizationContext synchronizationContext)
Parameters
| Type | Name | Description |
|---|---|---|
| String | eventName | The name of the observed event. |
| Type | eventSourceType | The type of the observable. |
| Delegate | eventHandler | A delegate that handles the specified event. |
| SynchronizationContext | synchronizationContext | The SynchronizationContext that the event delegate is to be executed on. |
Returns
| Type | Description |
|---|---|
| Boolean |
|
TryRegisterObserver<TEventArgs>(String, Type, EventHandler<TEventArgs>)
Registers an event delegate to handle a specific event published by a specific observable type.
Declaration
bool TryRegisterObserver<TEventArgs>(string eventName, Type eventSourceType, EventHandler<TEventArgs> eventHandler)
Parameters
| Type | Name | Description |
|---|---|---|
| String | eventName | The name of the observed event. |
| Type | eventSourceType | The type of the observable. |
| EventHandler<TEventArgs> | eventHandler | A delegate that handles the specified event. |
Returns
| Type | Description |
|---|---|
| Boolean |
|
Type Parameters
| Name | Description |
|---|---|
| TEventArgs | The type of the event args object. |
TryRegisterObserver<TEventArgs>(String, Type, EventHandler<TEventArgs>, Boolean)
Registers an event delegate to handle a specific event published by a specific observable type.
Declaration
bool TryRegisterObserver<TEventArgs>(string eventName, Type eventSourceType, EventHandler<TEventArgs> eventHandler, bool isMarshalEventToCurrentThreadEnabled)
Parameters
| Type | Name | Description |
|---|---|---|
| String | eventName | The name of the observed event. |
| Type | eventSourceType | The type of the observable. |
| EventHandler<TEventArgs> | eventHandler | A delegate that handles the specified event. |
| Boolean | isMarshalEventToCurrentThreadEnabled |
|
Returns
| Type | Description |
|---|---|
| Boolean |
|
Type Parameters
| Name | Description |
|---|---|
| TEventArgs | The type of the event args object. |
TryRegisterObserver<TEventArgs>(String, Type, EventHandler<TEventArgs>, SynchronizationContext)
Registers an event delegate to handle a specific event published by a specific observable type.
Declaration
bool TryRegisterObserver<TEventArgs>(string eventName, Type eventSourceType, EventHandler<TEventArgs> eventHandler, SynchronizationContext synchronizationContext)
Parameters
| Type | Name | Description |
|---|---|---|
| String | eventName | The name of the observed event. |
| Type | eventSourceType | The type of the observable. |
| EventHandler<TEventArgs> | eventHandler | A delegate that handles the specified event. |
| SynchronizationContext | synchronizationContext | The SynchronizationContext that the event delegate is to be executed on. |
Returns
| Type | Description |
|---|---|
| Boolean |
|
Type Parameters
| Name | Description |
|---|---|
| TEventArgs | The type of the event args object. |
TryRemoveAllObservers(String)
Removes all event handlers for a specified event no matter event publisher type.
Declaration
bool TryRemoveAllObservers(string eventName)
Parameters
| Type | Name | Description |
|---|---|---|
| String | eventName | The event name of the event that the delegate is handling. |
Returns
| Type | Description |
|---|---|
| Boolean |
|
TryRemoveAllObservers(String, Type)
Removes all event handlers for a specific event publisher type and specific event.
Declaration
bool TryRemoveAllObservers(string eventName, Type eventSourceType)
Parameters
| Type | Name | Description |
|---|---|---|
| String | eventName | The event name of the event that the delegate is handling. |
| Type | eventSourceType | The type of the event publisher. |
Returns
| Type | Description |
|---|---|
| Boolean |
|
TryRemoveAllObservers(Type)
Removes all event handlers for a specified event publisher type.
Declaration
bool TryRemoveAllObservers(Type eventSourceType)
Parameters
| Type | Name | Description |
|---|---|---|
| Type | eventSourceType | The type of the event publisher. |
Returns
| Type | Description |
|---|---|
| Boolean |
|
TryRemoveGlobalObserver(Delegate)
Removes the event handler for all registered events with a compatible event delegate signature.
Declaration
bool TryRemoveGlobalObserver(Delegate eventHandler)
Parameters
| Type | Name | Description |
|---|---|---|
| Delegate | eventHandler | The event handler to remove. |
Returns
| Type | Description |
|---|---|
| Boolean |
|
TryRemoveGlobalObserver(String, Delegate)
Removes the event handler for a specified event no matter the event publisher type.
Declaration
bool TryRemoveGlobalObserver(string eventName, Delegate eventHandler)
Parameters
| Type | Name | Description |
|---|---|---|
| String | eventName | The event name of the event that the delegate is handling. |
| Delegate | eventHandler | The event handler to remove |
Returns
| Type | Description |
|---|---|
| Boolean |
|
TryRemoveGlobalObserver<TEventArgs>(EventHandler<TEventArgs>)
Removes the event handler for all registered events with a compatible event delegate signature.
Declaration
bool TryRemoveGlobalObserver<TEventArgs>(EventHandler<TEventArgs> eventHandler)
Parameters
| Type | Name | Description |
|---|---|---|
| EventHandler<TEventArgs> | eventHandler | The event handler to remove. |
Returns
| Type | Description |
|---|---|
| Boolean |
|
Type Parameters
| Name | Description |
|---|---|
| TEventArgs | The type of the event args object. |
TryRemoveGlobalObserver<TEventArgs>(String, EventHandler<TEventArgs>)
Removes the event handler for a specified event no matter the event publisher type.
Declaration
bool TryRemoveGlobalObserver<TEventArgs>(string eventName, EventHandler<TEventArgs> eventHandler)
Parameters
| Type | Name | Description |
|---|---|---|
| String | eventName | The event name of the event that the delegate is handling. |
| EventHandler<TEventArgs> | eventHandler | The event handler to remove |
Returns
| Type | Description |
|---|---|
| Boolean |
|
Type Parameters
| Name | Description |
|---|---|
| TEventArgs | The type of the event args object. |
TryRemoveObservable(Object, Boolean)
Unregister the event publisher for all events.
Declaration
bool TryRemoveObservable(object eventSource, bool removeEventObservers = false)
Parameters
| Type | Name | Description |
|---|---|---|
| Object | eventSource | The event publisher instance. |
| Boolean | removeEventObservers | If |
Returns
| Type | Description |
|---|---|
| Boolean |
|
TryRemoveObservable(Object, IEnumerable<String>, Boolean)
Unregister the event publisher for a collection of specified events.
Declaration
bool TryRemoveObservable(object eventSource, IEnumerable<string> eventNames, bool removeEventObservers = false)
Parameters
| Type | Name | Description |
|---|---|---|
| Object | eventSource | The event publisher instance. |
| IEnumerable<String> | eventNames | The names of the events to unregister. |
| Boolean | removeEventObservers | If |
Returns
| Type | Description |
|---|---|
| Boolean |
|
TryRemoveObserver(String, Type, Delegate)
Removes the event handler for a specified event of a certain event publisher type.
Declaration
bool TryRemoveObserver(string eventName, Type eventSourceType, Delegate eventHandler)
Parameters
| Type | Name | Description |
|---|---|---|
| String | eventName | The event name of the event that the delegate is handling. |
| Type | eventSourceType | The type of the event publisher. |
| Delegate | eventHandler | The event handler to remove. |
Returns
| Type | Description |
|---|---|
| Boolean |
|
TryRemoveObserver<TEventArgs>(String, Type, EventHandler<TEventArgs>)
Removes the event handler for a specified event of a certain event publisher type.
Declaration
bool TryRemoveObserver<TEventArgs>(string eventName, Type eventSourceType, EventHandler<TEventArgs> eventHandler)
Parameters
| Type | Name | Description |
|---|---|---|
| String | eventName | The event name of the event that the delegate is handling. |
| Type | eventSourceType | The type of the event publisher. |
| EventHandler<TEventArgs> | eventHandler | The event handler to remove. |
Returns
| Type | Description |
|---|---|
| Boolean |
|
Type Parameters
| Name | Description |
|---|---|
| TEventArgs | The type of the event args object. |