Table of Contents

Class MessagesSource<TBaseEvent>

Namespace
Silverback.Messaging.Messages
Assembly
Silverback.Core.dll

The default generic implementation of IMessagesSource. It contains some protected methods to add the internal events to a temporary collection exposed via the IMessagesSource implementation.

public abstract class MessagesSource<TBaseEvent> : IMessagesSource

Type Parameters

TBaseEvent

The base type of the events being published.

Inheritance
MessagesSource<TBaseEvent>
Implements
Derived
Inherited Members

Remarks

This is the base class of the DomainEntity defined in Silverback.Core.Model.

Constructors

MessagesSource()

protected MessagesSource()

Methods

AddEvent(TBaseEvent)

Adds the specified event to the collection of events related to this object.

In the case of an entity model the event will be published when the entity is saved to the underlying database.

protected virtual void AddEvent(TBaseEvent @event)

Parameters

event TBaseEvent

The instance of TBaseEvent to be added.

AddEvent<TEvent>(bool)

Adds a new instance of TEvent to the collection of events related to this object.

In the case of an entity model the event will be published when the entity is saved to the underlying database.

protected TEvent AddEvent<TEvent>(bool allowMultiple = true) where TEvent : TBaseEvent, new()

Parameters

allowMultiple bool

if set to false only one instance of the specified type TEvent will be added.

Returns

TEvent

The TEvent instance that was added.

Type Parameters

TEvent

The type of the event.

ClearMessages()

Called after the messages have been successfully published (and processed) to clear the messages collection.

public void ClearMessages()

GetMessages()

Gets the messages to be published.

public IEnumerable<object>? GetMessages()

Returns

IEnumerable<object>

The message objects.

RemoveEvent(TBaseEvent)

Removes the specified event from the collection of events related to this object.

protected void RemoveEvent(TBaseEvent @event)

Parameters

event TBaseEvent

The TBaseEvent to be removed.

Remarks

This is used only to withdraw an event that wasn't published yet.