Send extension method

Send extension method is used to notify subscribed observers that event happened.

Send extension method signature
public static EventMessage Send(this object eventSource, EventHub eventHub, int id, params KeyValuePair<string, object>[] parameters)

Input arguments
  • eventSource is an event source, i.e. the object that sends an event message
  • eventHub is an object that manages event messaging
  • id is an event message identifier
  • parameters are optional parameters providing data for event handlers
Return value
  • eventMessage is an instance of the sended message processed by all subscribed handlers

Example

Send an event message with Dispatch ID (int this example EventId.settings file defines parameter with key "Dispatch" and some integer number as a value).

Provide event message with specified delegate as an event argument (parameter key "Dispatch" and parameter value is an Action delegate).

this.Send(EventId.Default.Dispatch,
  new KeyValuePair<string, object>(
    "Dispatch",
    new Action(() => IsExecutable = eventMessage.GetValue<bool>("WorkIsDone"))));

All subscribers to specified event ID (EventId.Default.Dispatch) will receive this event message.

Last edited Apr 19, 2012 at 7:13 PM by DarkVasya, version 4

Comments

No comments yet.