Class NotificationService
Implements a simple notification service.
Implements
Namespace: Sartorius.SAF.Notification
Assembly: Sartorius.SAF.dll
Syntax
[Export(typeof(INotificationService))]
public class NotificationService : INotificationService
Methods
View SourceDoPublish<T>(T)
Publishes the notification to all subscribers.
Declaration
protected virtual void DoPublish<T>(T notification)
Parameters
Type | Name | Description |
---|---|---|
T | notification | The arguments that are passed to the subscribers. |
Type Parameters
Name | Description |
---|---|
T |
DoSubscribe<T>(Action<T>, Boolean, Predicate<T>)
Subscribes a delegate to an event.
Declaration
protected virtual SubscriptionToken DoSubscribe<T>(Action<T> action, bool keepSubscriberReferenceAlive, Predicate<T> filter)
Parameters
Type | Name | Description |
---|---|---|
System.Action<T> | action | The delegate that gets executed when the payload is published. |
System.Boolean | keepSubscriberReferenceAlive | When true, the CompositePresentationEvent keeps a reference to the subscriber so it does not get garbage collected. |
System.Predicate<T> | filter | Filter to evaluate if the subscriber should receive the event. |
Returns
Type | Description |
---|---|
SubscriptionToken | A SubscriptionToken that uniquely identifies the added subscription. |
Type Parameters
Name | Description |
---|---|
T |
DoUnsubscribe(SubscriptionToken)
Removes the subscriber matching the SubscriptionToken.
Declaration
protected virtual void DoUnsubscribe(SubscriptionToken subscriptionToken)
Parameters
Type | Name | Description |
---|---|---|
SubscriptionToken | subscriptionToken | The SubscriptionToken. |
Explicit Interface Implementations
View SourceINotificationService.Publish<T>(T)
Publishes the specific notification.
Declaration
void INotificationService.Publish<T>(T notification)
Parameters
Type | Name | Description |
---|---|---|
T | notification | The payload. |
Type Parameters
Name | Description |
---|---|
T | The |
INotificationService.Subscribe<T>(Action<T>)
Subscribes the action
to the notifications of T
.
Declaration
SubscriptionToken INotificationService.Subscribe<T>(Action<T> action)
Parameters
Type | Name | Description |
---|---|---|
System.Action<T> | action | The System.Action<T> that is invoked when the notification is published. |
Returns
Type | Description |
---|---|
SubscriptionToken |
Type Parameters
Name | Description |
---|---|
T | The notification type. |
INotificationService.Subscribe<T>(Action<T>, Predicate<T>)
Subscribes the action
with the given filter
to the notifications of T
.
Declaration
SubscriptionToken INotificationService.Subscribe<T>(Action<T> action, Predicate<T> filter)
Parameters
Type | Name | Description |
---|---|---|
System.Action<T> | action | The System.Action<T> that is invoked when the notification is published. |
System.Predicate<T> | filter | The filter System.Predicate<T> that defines whether the notification is published to the subscriber. |
Returns
Type | Description |
---|---|
SubscriptionToken |
Type Parameters
Name | Description |
---|---|
T | The payload type. |
INotificationService.Unsubscribe(SubscriptionToken)
Removes the subscriber matching the SubscriptionToken.
Declaration
void INotificationService.Unsubscribe(SubscriptionToken subscriptionToken)
Parameters
Type | Name | Description |
---|---|---|
SubscriptionToken | subscriptionToken | The SubscriptionToken. |