laatzen/Common/Service/MeterProcessState/Global.asax.cs
2025-06-18 07:43:05 +02:00

37 lines
1.3 KiB
C#

namespace Service.MeterProcessState
{
using Newtonsoft.Json;
using System;
using System.Web;
using System.Web.Http;
using System.Web.Mvc;
using System.Web.Optimization;
using System.Web.Routing;
public class WebApiApplication : HttpApplication
{
protected void Application_Start()
{
AreaRegistration.RegisterAllAreas();
GlobalConfiguration.Configure(WebApiConfig.Register);
FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
RouteConfig.RegisterRoutes(RouteTable.Routes);
BundleConfig.RegisterBundles(BundleTable.Bundles);
// GlobalConfiguration.Configuration.Formatters.JsonFormatter.SerializerSettings.Converters.Add(new Bytes2StringConverter());
}
}
public class Bytes2StringConverter : JsonConverter<byte[]>
{
public override Byte[] ReadJson(JsonReader reader, Type objectType, byte[] existingValue, bool hasExistingValue, JsonSerializer serializer)
{
throw new NotImplementedException();
}
public override void WriteJson(JsonWriter writer, byte[] value, JsonSerializer serializer)
=> writer.WriteValue(BitConverter.ToString(value ?? Array.Empty<byte>()));
}
}