Class MessagesSource<TBaseEvent>
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.
Inheritance
Implements
Inherited Members
Namespace: Silverback.Messaging.Messages
Assembly: Silverback.Core.dll
Syntax
public abstract class MessagesSource<TBaseEvent> : IMessagesSource
Type Parameters
Name | Description |
---|---|
TBaseEvent | The base type of the events being published. |
Remarks
This is the base class of the DomainEntity
defined in Silverback.Core.Model.
Methods
| Improve this doc View sourceAddEvent(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.
Declaration
protected virtual void AddEvent(TBaseEvent @event)
Parameters
Type | Name | Description |
---|---|---|
TBaseEvent | event | The instance of |
Remarks
This is the base class of the DomainEntity
defined in Silverback.Core.Model.
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.
Declaration
protected TEvent AddEvent<TEvent>(bool allowMultiple = true) where TEvent : TBaseEvent, new()
Parameters
Type | Name | Description |
---|---|---|
bool | allowMultiple | if set to |
Returns
Type | Description |
---|---|
TEvent | The |
Type Parameters
Name | Description |
---|---|
TEvent | The type of the event. |
Remarks
This is the base class of the DomainEntity
defined in Silverback.Core.Model.
ClearMessages()
Called after the messages have been successfully published (and processed) to clear the messages collection.
Declaration
public void ClearMessages()
Remarks
This is the base class of the DomainEntity
defined in Silverback.Core.Model.
GetMessages()
Gets the messages to be published.
Declaration
public IEnumerable<object>? GetMessages()
Returns
Type | Description |
---|---|
IEnumerable<object> | The message objects. |
Remarks
This is the base class of the DomainEntity
defined in Silverback.Core.Model.
RemoveEvent(TBaseEvent)
Removes the specified event from the collection of events related to this object.
Declaration
protected void RemoveEvent(TBaseEvent @event)
Parameters
Type | Name | Description |
---|---|---|
TBaseEvent | event | The |
Remarks
This is used only to withdraw an event that wasn't published yet.