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
DefaultPenningtonYamlContextProvider- 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
contextsIEnumerable<YamlSerializerContext>- Registered contexts; the built-in
PenningtonYamlContextis 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
yamlstring- Raw YAML text.
Returns
TPennington.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)
;
}