Table of Contents

MetadataFactory Class

Definition

Namespace
Savvyio
Assemblies
Savvyio.Core.dll
Source
src/Savvyio.Core/MetadataFactory.cs

Provides access to factory methods for maintaining metadata in models.

public static class MetadataFactory
Inheritance
MetadataFactory

Examples

This example shows how to persist a custom metadata value on a request and retrieve it later in the pipeline.

using Savvyio;

namespace ExampleApp;

public sealed class MetadataFactoryExample
{
    public string GetTenant()
    {
        var command = new CreateOrderCommand("ORD-42");
        MetadataFactory.Set(command, "tenant", "eu-west");
        return (string)MetadataFactory.Get(command, "tenant");
    }
}

public sealed record CreateOrderCommand(string OrderId) : Request;

Methods

Name Description
Get<T>(T, string)

Gets the value associates to the request from the item with the specified key.

Set<T>(T, string, object)

Assigns a new value to the request on the item with the specified key.