MetadataExtensions Class
Definition
Extension methods for the IMetadata interface.
public static class MetadataExtensions
- Inheritance
-
MetadataExtensions
Examples
This example shows how a request can collect reserved metadata, merge values from an upstream request, and read the normalized values back again. The workflow exercises the metadata helpers that are typically used by command, event, and integration-message pipelines.
using System;
using Savvyio;
namespace ExampleApp;
public sealed class MetadataExtensionsExample
{
public (string CorrelationId, string MemberType, string Tenant) Enrich()
{
var parent = new CreateOrderCommand("ORD-41").SetCorrelationId("corr-41").SaveMetadata("tenant", "eu-west");
var command = new CreateOrderCommand("ORD-42")
.SetCorrelationId("corr-42")
.SetCausationId("checkout")
.SetRequestId("req-42")
.SetEventId("evt-42")
.SetMemberType(typeof(CreateOrderCommand))
.SetTimestamp(new DateTime(2026, 7, 1, 0, 0, 0, DateTimeKind.Utc))
.MergeMetadata(parent);
var correlationId = command.GetCorrelationId();
var causationId = command.GetCausationId();
var requestId = command.GetRequestId();
var memberType = command.GetMemberType();
return (correlationId, memberType, (string)command.Metadata["tenant"]);
}
}
public sealed record CreateOrderCommand(string OrderId) : Request;
Methods
| Name | Description |
|---|---|
| GetCausationId<T>(T) | Gets the string representation of the causation identifier from the |
| GetCorrelationId<T>(T) | Gets the string representation of the correlation identifier from the |
| GetMemberType<T>(T) | Gets the string representation of the underlying member type of |
| GetRequestId<T>(T) | Gets the string representation of the request identifier from the |
| MergeMetadata<TSource, TDestination>(TDestination, TSource) | Copies model from the |
| SaveMetadata<T>(T, string, object) | Add or update a set of model to the |
| SetCausationId<T>(T, string) | Assigns a new |
| SetCorrelationId<T>(T, string) | Assigns a new |
| SetEventId<T>(T, string) | Assigns a new |
| SetMemberType<T>(T, Type) | Assigns a new |
| SetRequestId<T>(T, string) | Assigns a new |
| SetTimestamp<T>(T, DateTime?) | Assigns a new timestamp (UtcNow value) to the |