Path: redb-route/redb.Route.DataFormats.Csv/CsvRouteDefinitionExtensions.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.DataFormats.Csv/CsvRouteDefinitionExtensions.cs
----
using redb.Route.Abstractions;
using redb.Route.Extensions;
namespace redb.Route.DataFormats.Csv;
/// DSL and registration sugar for .
public static class CsvRouteDefinitionExtensions
{
/// Marshals the body to CSV with per-node options.
public static IRouteDefinition MarshalCsv(this IRouteDefinition route, Action? configure = null)
=> route.Marshal(new CsvDataFormat(Build(configure)));
/// Unmarshals CSV to (List<Row>, Row[], List<Dictionary<string,string>>, List<string[]>) with per-node options.
public static IRouteDefinition UnmarshalCsv(this IRouteDefinition route, Action? configure = null)
=> route.Unmarshal(new CsvDataFormat(Build(configure)));
/// Registers CSV as text/csv on the context, for Marshal("text/csv"), Unmarshal<T>("text/csv") and content-type-driven Unmarshal<T>().
public static IRouteContext AddCsvDataFormat(this IRouteContext context, Action? configure = null)
=> context.AddDataFormat(new CsvDataFormat(Build(configure)), CsvDataFormat.Name);
/// DI form of .
public static RedbRouteBuilder AddCsvDataFormat(this RedbRouteBuilder builder, Action? configure = null)
=> builder.AddDataFormat(new CsvDataFormat(Build(configure)), CsvDataFormat.Name);
private static CsvDataFormatOptions Build(Action? configure)
{
var options = new CsvDataFormatOptions();
configure?.Invoke(options);
return options;
}
}