67 lines
2.5 KiB
C#
67 lines
2.5 KiB
C#
// TEMPORARILY DISABLED: this file references Microsoft.AspNetCore.Mvc.* which collides with the
|
|
// downstream Hybrid client (FruitBankHybrid.Web.Client targets net10.0 and breaks on the
|
|
// AspNetCore.Mvc namespace). Re-enable when the binary serializer + MVC formatter is moved to
|
|
// its own solution / NuGet package. The FrameworkReference Microsoft.AspNetCore.App in
|
|
// AyCode.Services.csproj is also disabled in tandem.
|
|
|
|
/*
|
|
using AyCode.Core.Serializers.Binaries;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
namespace AyCode.Services.Mvc;
|
|
|
|
/// <summary>
|
|
/// MVC builder extensions to register AcBinary input/output formatters.
|
|
/// Inserts at index 0 — AcBinary is preferred when the client's Accept header allows.
|
|
/// </summary>
|
|
public static class AcBinaryMvcBuilderExtensions
|
|
{
|
|
/// <summary>
|
|
/// Registers AcBinary input + output formatters on the MVC pipeline. Pass <paramref name="configure"/>
|
|
/// to customize <see cref="AcBinarySerializerOptions"/>; otherwise
|
|
/// <see cref="AcBinarySerializerOptions.Default"/> is used.
|
|
/// </summary>
|
|
public static IMvcBuilder AddAcBinaryFormatters(this IMvcBuilder builder, Action<AcBinarySerializerOptions>? configure = null)
|
|
{
|
|
if (builder is null) throw new ArgumentNullException(nameof(builder));
|
|
|
|
var options = AcBinarySerializerOptions.Default;
|
|
if (configure != null)
|
|
{
|
|
options = new AcBinarySerializerOptions();
|
|
configure(options);
|
|
}
|
|
|
|
builder.Services.Configure<MvcOptions>(opts =>
|
|
{
|
|
opts.InputFormatters.Insert(0, new AcBinaryInputFormatter(options));
|
|
opts.OutputFormatters.Insert(0, new AcBinaryOutputFormatter(options));
|
|
});
|
|
|
|
return builder;
|
|
}
|
|
|
|
/// <inheritdoc cref="AddAcBinaryFormatters(IMvcBuilder, Action{AcBinarySerializerOptions}?)"/>
|
|
public static IMvcCoreBuilder AddAcBinaryFormatters(this IMvcCoreBuilder builder, Action<AcBinarySerializerOptions>? configure = null)
|
|
{
|
|
if (builder is null) throw new ArgumentNullException(nameof(builder));
|
|
|
|
var options = AcBinarySerializerOptions.Default;
|
|
if (configure != null)
|
|
{
|
|
options = new AcBinarySerializerOptions();
|
|
configure(options);
|
|
}
|
|
|
|
builder.Services.Configure<MvcOptions>(opts =>
|
|
{
|
|
opts.InputFormatters.Insert(0, new AcBinaryInputFormatter(options));
|
|
opts.OutputFormatters.Insert(0, new AcBinaryOutputFormatter(options));
|
|
});
|
|
|
|
return builder;
|
|
}
|
|
}
|
|
*/
|