24 lines
767 B
C#
24 lines
767 B
C#
using Microsoft.AspNetCore.Mvc.ModelBinding.Metadata;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Text;
|
|
|
|
namespace Saxonite.Net.Core.Web.Base.Middleware
|
|
{
|
|
//=======================================================================
|
|
/// <summary>
|
|
/// Force blank form values to be populated to the model as empty strings rather than null values.
|
|
/// </summary>
|
|
public class SaxMetadataProvider : IMetadataDetailsProvider, IDisplayMetadataProvider
|
|
{
|
|
public void CreateDisplayMetadata(DisplayMetadataProviderContext context)
|
|
{
|
|
if (context.Key.MetadataKind == ModelMetadataKind.Property)
|
|
{
|
|
context.DisplayMetadata.ConvertEmptyStringToNull = false;
|
|
}
|
|
}
|
|
}
|
|
//=======================================================================
|
|
}
|