Path: redb-route/redb.Route/Abstractions/IDataFormatRegistry.cs
Snapshot: redb-route, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb-route
Page: https://redbase.app/src/dev-2026-12-06/redb-route/redb.Route/Abstractions/IDataFormatRegistry.cs
----
namespace redb.Route.Abstractions;
///
/// Registry of content-type → serializer mappings.
/// Used by -based processors to auto-select
/// the appropriate serializer based on the exchange's ContentType.
///
/// Two lookup dimensions are supported:
///
///
/// - Media type — resolves by MIME string
/// (application/json, application/scim+json). Used for wire-format
/// interop; honors RFC 6838 structured-suffix fallbacks (+json/+xml).
/// - Profile name — resolves by a caller-chosen alias
/// (e.g. "scim", "problem"). Used by application code that wants a
/// named preset independent of the wire media type.
///
///
public interface IDataFormatRegistry
{
/// Finds a serializer for the given content type (e.g. "application/json").
/// MIME content type, optionally with parameters (charset, etc.).
/// Matching serializer, or null if none registered.
IMessageSerializer? GetSerializer(string contentType);
/// Registers a serializer for the given content type.
/// MIME content type (e.g. "application/json").
/// Serializer instance.
void Register(string contentType, IMessageSerializer serializer);
///
/// Resolves a serializer registered under a named profile (e.g. "scim",
/// "problem", "oauth"). Profiles are separate from media-type lookup —
/// used by application code that selects a preset by name rather than by wire media type.
///
/// Profile alias.
/// Matching serializer, or null if no profile by that name is registered.
///
/// Default implementation returns null; registries that don't care about profiles
/// remain source-compatible with the original contract.
///
IMessageSerializer? ResolveProfile(string profileName) => null;
///
/// Registers a serializer under a named profile alias.
///
/// Profile alias (e.g. "scim").
/// Serializer instance.
///
/// Default implementation is a no-op, preserving source compatibility with
/// external implementations.
///
void RegisterProfile(string profileName, IMessageSerializer serializer) { }
}