This documentation is also published as Markdown for efficient machine reading: the whole site is indexed at /llms.txt, and every page has a clean Markdown copy under /_llms/. These are generated from the same source and cost far fewer tokens to read than this rendered HTML.

Skip to main content Skip to navigation

PenningtonYamlContextProvider Pennington.FrontMatter

Routes a type to the registered YamlSerializerContext that knows it — the built-in PenningtonYamlContext, a satellite package context, or one a user added via AddYamlContext — and falls back to reflection for everything else. A source-generated context only serves the types it was generated for and rejects foreign options, so each type is dispatched to its own context rather than combined into a single resolver.

Properties

Default PenningtonYamlContextProvider
A provider seeded with only the built-in context, for non-DI use (tests, scripts).

Constructors

PenningtonYamlContextProvider

#
public PenningtonYamlContextProvider(IEnumerable<YamlSerializerContext> contexts)

Initializes the provider with the serializer contexts registered in DI.

Parameters

contexts IEnumerable<YamlSerializerContext>
Registered contexts; the built-in PenningtonYamlContext is always present.

Methods

Deserialize<T>

#
public T Deserialize<T>(string yaml)

Deserializes yaml into T using the source-generated context that covers T, or reflection when none does.

Parameters

yaml string
Raw YAML text.

Returns

T

Pennington.FrontMatter.PenningtonYamlContextProvider

namespace Pennington.FrontMatter;

/// Routes a type to the registered YamlSerializerContext that knows it — the built-in PenningtonYamlContext, a satellite package context, or one a user added via AddYamlContext — and falls back to reflection for everything else. A source-generated context only serves the types it was generated for and rejects foreign options, so each type is dispatched to its own context rather than combined into a single resolver.
public class PenningtonYamlContextProvider
{
    /// A provider seeded with only the built-in context, for non-DI use (tests, scripts).
    
public static PenningtonYamlContextProvider Default { get; }
/// Deserializes yaml into T using the source-generated context that covers T, or reflection when none does.
public T Deserialize<T>(string yaml)
; /// Initializes the provider with the serializer contexts registered in DI.
public PenningtonYamlContextProvider(IEnumerable<YamlSerializerContext> contexts)
; }