Registration by Event Broker Registrar
When your scenario for registering events or event handler methods cannot be achieved with attributes, you can use the event broker registrar to register events or handler methods via code.
To use the registrar, implement the interface IEventBrokerRegisterable
in your publisher or subscriber:
Register Events of the same Class
Events of the same class can be registered by using eventRegistrar.AddPublication(...)
.
You need to specify the event topic, the instance used as publisher (normally this
), the event, the handler restriction
and optionally publication matchers.
Register Event Handler Methods of the same Class
Event handler methods of the same class can be registered by using eventRegistrar.AddSubscription(...)
.
You need to specify the event topic, the instance used as subscriber (normally this
), the event handler method
and optionally subscription matchers.
Register Events of other Classes
You can register events of other classes by using eventRegistrar.RegisterEvent(...)
and specifying
the event topic, the instance to use as the publisher, the name of the event on the class providing the event,
the handler restriction and optionally publication matchers.
This feature is also available directly on the event broker so you don't have to use an intermediate publisher just for adding an event of another class.
Register Event Handler Methods of other Classes
You can register event handler methods of other classes by using eventRegistrar.RegisterHandlerMethod(...)
and specifying
the event topic, the instance to use as the subscriber, the handler method on the other class and optionally subscription matchers.
This feature is also available directly on the event broker so you don't have to use an intermediate subscriber just for adding an event handler method of another class.
Register/Unregister additional Instances
Use eventRegistrar.Register(object item)
and eventRegistrar.Unregister(object item)
to register and unregister
additional items - for example private instances of the class - on the event broker.