Class DomainEventExtensions
Extension methods for the IDomainEvent interface.
public static class DomainEventExtensions
- Inheritance
-
DomainEventExtensions
Examples
This example shows how to stamp a domain event with envelope metadata and read the event identifier and timestamp later.
using System;
using Savvyio;
using Savvyio.Domain;
namespace ExampleApp;
public sealed class DomainEventExtensionsExample
{
public (string EventId, DateTime Timestamp) Describe()
{
var e = new AccountOpenedEvent("ACC-42").SetEventId("evt-42").SetTimestamp(new DateTime(2026,7,1,0,0,0,DateTimeKind.Utc));
return (e.GetEventId(), e.GetTimestamp());
}
}
public sealed record AccountOpenedEvent(string AccountId) : Request, IDomainEvent;
Methods
GetEventId<T>(T)
Gets the string representation of the event identifier from the request.
public static string GetEventId<T>(this T request) where T : IDomainEvent
Parameters
requestTThe ITracedDomainEvent to extend.
Returns
- string
The string representation of the event identifier from the
request.
Type Parameters
TThe model that implements the ITracedDomainEvent interface.
GetTimestamp<T>(T)
Gets the DateTime value of the timestamp from the request.
public static DateTime GetTimestamp<T>(this T request) where T : IDomainEvent
Parameters
requestTThe ITracedDomainEvent to extend.
Returns
Type Parameters
TThe model that implements the ITracedDomainEvent interface.