Pip-Services-Commons-Dotnet
Public Member Functions | Properties | List of all members
PipServices3.Commons.Commands.Event Class Reference

Concrete implementation of IEvent interface. It allows to send asynchronous notifications to multiple subscribed listeners. More...

Inheritance diagram for PipServices3.Commons.Commands.Event:
PipServices3.Commons.Commands.IEvent PipServices3.Commons.Run.INotifiable

Public Member Functions

 Event (string name)
 Creates a new event and assigns its name. More...
 
void AddListener (IEventListener listener)
 Adds a listener to receive notifications when this event is fired. More...
 
void RemoveListener (IEventListener listener)
 Removes a listener, so that it no longer receives notifications for this event. More...
 
async Task NotifyAsync (string correlationId, Parameters args)
 Fires this event and notifies all registered listeners. More...
 

Properties

string Name [get]
 Gets the name of the event. More...
 
List< IEventListenerListeners [get]
 Gets all listeners registered in this event. More...
 
- Properties inherited from PipServices3.Commons.Commands.IEvent
string Name [get]
 Gets the event name. More...
 
List< IEventListenerListeners [get]
 Gets the listeners that receive notifications for this event. More...
 

Detailed Description

Concrete implementation of IEvent interface. It allows to send asynchronous notifications to multiple subscribed listeners.

var event = new Event("my_event");
event.addListener(myListener);
event.notify("123", Parameters.fromTuples(
"param1", "ABC",
"param2", 123 ));

See IEvent, IEventListener

Constructor & Destructor Documentation

◆ Event()

PipServices3.Commons.Commands.Event.Event ( string  name)

Creates a new event and assigns its name.

Parameters
nameThe name of the event.
Exceptions
ArgumentNullExceptionan Error if the name is null.

Member Function Documentation

◆ AddListener()

void PipServices3.Commons.Commands.Event.AddListener ( IEventListener  listener)

Adds a listener to receive notifications when this event is fired.

Parameters
listenerTthe listener reference to add.

Implements PipServices3.Commons.Commands.IEvent.

◆ NotifyAsync()

async Task PipServices3.Commons.Commands.Event.NotifyAsync ( string  correlationId,
Parameters  args 
)

Fires this event and notifies all registered listeners.

Parameters
correlationIdUnique correlation/transaction id.
argsThe event arguments/value.
Exceptions
InvocationExceptionif the event fails to be raised.

Implements PipServices3.Commons.Run.INotifiable.

◆ RemoveListener()

void PipServices3.Commons.Commands.Event.RemoveListener ( IEventListener  listener)

Removes a listener, so that it no longer receives notifications for this event.

Parameters
listenerthe listener reference to remove.

Implements PipServices3.Commons.Commands.IEvent.

Property Documentation

◆ Listeners

List<IEventListener> PipServices3.Commons.Commands.Event.Listeners
get

Gets all listeners registered in this event.

◆ Name

string PipServices3.Commons.Commands.Event.Name
get

Gets the name of the event.


The documentation for this class was generated from the following file: