@ -1,246 +1,262 @@
@@ -1,246 +1,262 @@
// <auto-generated />
//
// To parse this JSON data, add NuGet 'Newtonsof t.Json' then do:
// To parse this JSON data, add NuGet 'System.Tex t.Json' then do:
//
// using ErsatzTV.Core.Next.Config;
//
// var channelConfig = ChannelConfig.FromJson(jsonString);
# nullable enable
#pragma warning disable CS8618
#pragma warning disable CS8601
#pragma warning disable CS8602
#pragma warning disable CS8603
namespace ErsatzTV.Core.Next.Config
{
using System ;
using System.Collections.Generic ;
using System.Text.Json ;
using System.Text.Json.Serialization ;
using System.Globalization ;
using Newtonsoft.Json ;
using Newtonsoft.Json.Converters ;
public partial class ChannelConfig
{
[JsonProperty("ffmpeg")]
[JsonPropertyName ("ffmpeg")]
public Ffmpeg Ffmpeg { get ; set ; }
[JsonProperty("normalization")]
[JsonPropertyName ("normalization")]
public Normalization Normalization { get ; set ; }
[JsonProperty("playout")]
[JsonPropertyName ("playout")]
public Playout Playout { get ; set ; }
}
public partial class Ffmpeg
{
[JsonProperty("disabled_filters", NullValueHandling = NullValueHandling.Ignore)]
public List < string > DisabledFilters { get ; set ; }
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
[JsonPropertyName("disabled_filters")]
public List < string > ? DisabledFilters { get ; set ; }
[JsonProperty("ffmpeg_path")]
public string FfmpegPath { get ; set ; }
[JsonPropertyName ("ffmpeg_path")]
public string? FfmpegPath { get ; set ; }
[JsonProperty("ffprobe_path")]
public string FfprobePath { get ; set ; }
[JsonPropertyName ("ffprobe_path")]
public string? FfprobePath { get ; set ; }
[JsonProperty("preferred_filters", NullValueHandling = NullValueHandling.Ignore)]
public List < string > PreferredFilters { get ; set ; }
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
[JsonPropertyName("preferred_filters")]
public List < string > ? PreferredFilters { get ; set ; }
[JsonProperty("reports_folder")]
public string ReportsFolder { get ; set ; }
[JsonPropertyName ("reports_folder")]
public string? ReportsFolder { get ; set ; }
}
public partial class Normalization
{
[JsonProperty("audio")]
[JsonPropertyName ("audio")]
public Audio Audio { get ; set ; }
[JsonProperty("subtitle", NullValueHandling = NullValueHandling.Ignore)]
public Subtitle Subtitle { get ; set ; }
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
[JsonPropertyName("subtitle")]
public Subtitle ? Subtitle { get ; set ; }
[JsonProperty("video")]
[JsonPropertyName ("video")]
public Video Video { get ; set ; }
}
public partial class Audio
{
[JsonProperty("bitrate_kbps")]
[JsonPropertyName ("bitrate_kbps")]
public long? BitrateKbps { get ; set ; }
[JsonProperty("buffer_kbps")]
[JsonPropertyName ("buffer_kbps")]
public long? BufferKbps { get ; set ; }
[JsonProperty("channels")]
[JsonPropertyName ("channels")]
public long? Channels { get ; set ; }
[JsonProperty("format")]
[JsonPropertyName ("format")]
public AudioFormat ? Format { get ; set ; }
[JsonProperty("loudness")]
public LoudnessClass Loudness { get ; set ; }
[JsonPropertyName ("loudness")]
public LoudnessClass ? Loudness { get ; set ; }
[JsonProperty("normalize_loudness", NullValueHandling = NullValueHandling.Ignore)]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
[JsonPropertyName("normalize_loudness")]
public bool? NormalizeLoudness { get ; set ; }
[JsonProperty("sample_rate_hz")]
[JsonPropertyName ("sample_rate_hz")]
public long? SampleRateHz { get ; set ; }
}
public partial class LoudnessClass
{
[JsonProperty("integrated_target")]
[JsonPropertyName ("integrated_target")]
public double? IntegratedTarget { get ; set ; }
[JsonProperty("range_target")]
[JsonPropertyName ("range_target")]
public double? RangeTarget { get ; set ; }
[JsonProperty("true_peak")]
[JsonPropertyName ("true_peak")]
public double? TruePeak { get ; set ; }
}
public partial class Subtitle
{
[JsonProperty("mode", NullValueHandling = NullValueHandling.Ignore)]
[JsonPropertyName("fonts_folder")]
public string? FontsFolder { get ; set ; }
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
[JsonPropertyName("mode")]
public Mode ? Mode { get ; set ; }
}
public partial class Video
{
[JsonProperty("accel")]
[JsonPropertyName ("accel")]
public AccelEnum ? Accel { get ; set ; }
[JsonProperty("bit_depth")]
[JsonPropertyName ("bit_depth")]
public long? BitDepth { get ; set ; }
[JsonProperty("bitrate_kbps")]
[JsonPropertyName ("bitrate_kbps")]
public long? BitrateKbps { get ; set ; }
[JsonProperty("buffer_kbps")]
[JsonPropertyName ("buffer_kbps")]
public long? BufferKbps { get ; set ; }
[JsonProperty("deinterlace", NullValueHandling = NullValueHandling.Ignore)]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
[JsonPropertyName("deinterlace")]
public bool? Deinterlace { get ; set ; }
[JsonProperty("filters", NullValueHandling = NullValueHandling.Ignore)]
public Filters Filters { get ; set ; }
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
[JsonPropertyName("filters")]
public Filters ? Filters { get ; set ; }
[JsonProperty("format")]
[JsonPropertyName ("format")]
public VideoFormat ? Format { get ; set ; }
[JsonProperty("height")]
[JsonPropertyName ("height")]
public long? Height { get ; set ; }
[JsonProperty("scaling_mode", NullValueHandling = NullValueHandling.Ignore)]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
[JsonPropertyName("scaling_mode")]
public ScalingMode ? ScalingMode { get ; set ; }
[JsonProperty("vaapi_device")]
public string VaapiDevice { get ; set ; }
[JsonPropertyName ("vaapi_device")]
public string? VaapiDevice { get ; set ; }
[JsonProperty("vaapi_driver")]
[JsonPropertyName ("vaapi_driver")]
public VaapiDriverEnum ? VaapiDriver { get ; set ; }
[JsonProperty("width")]
[JsonPropertyName ("width")]
public long? Width { get ; set ; }
}
public partial class Filters
{
[JsonProperty("bwdif")]
public BwdifClass Bwdif { get ; set ; }
[JsonPropertyName ("bwdif")]
public BwdifClass ? Bwdif { get ; set ; }
[JsonProperty("bwdif_cuda")]
public BwdifCudaClass BwdifCuda { get ; set ; }
[JsonPropertyName ("bwdif_cuda")]
public BwdifCudaClass ? BwdifCuda { get ; set ; }
[JsonProperty("deinterlace_qsv")]
public DeinterlaceQsvClass DeinterlaceQsv { get ; set ; }
[JsonPropertyName ("deinterlace_qsv")]
public DeinterlaceQsvClass ? DeinterlaceQsv { get ; set ; }
[JsonProperty("deinterlace_vaapi")]
public DeinterlaceVaapiClass DeinterlaceVaapi { get ; set ; }
[JsonPropertyName ("deinterlace_vaapi")]
public DeinterlaceVaapiClass ? DeinterlaceVaapi { get ; set ; }
[JsonProperty("libplacebo")]
public LibplaceboClass Libplacebo { get ; set ; }
[JsonPropertyName ("libplacebo")]
public LibplaceboClass ? Libplacebo { get ; set ; }
[JsonProperty("tonemap")]
public TonemapClass Tonemap { get ; set ; }
[JsonPropertyName ("tonemap")]
public TonemapClass ? Tonemap { get ; set ; }
[JsonProperty("tonemap_opencl")]
public TonemapOpenclClass TonemapOpencl { get ; set ; }
[JsonPropertyName ("tonemap_opencl")]
public TonemapOpenclClass ? TonemapOpencl { get ; set ; }
[JsonProperty("w3fdif")]
public W3FdifClass W3Fdif { get ; set ; }
[JsonPropertyName ("w3fdif")]
public W3FdifClass ? W3Fdif { get ; set ; }
[JsonProperty("yadif")]
public YadifClass Yadif { get ; set ; }
[JsonPropertyName ("yadif")]
public YadifClass ? Yadif { get ; set ; }
[JsonProperty("yadif_cuda")]
public YadifCudaClass YadifCuda { get ; set ; }
[JsonPropertyName ("yadif_cuda")]
public YadifCudaClass ? YadifCuda { get ; set ; }
}
public partial class BwdifClass
{
[JsonProperty("mode")]
public string Mode { get ; set ; }
[JsonPropertyName ("mode")]
public string? Mode { get ; set ; }
}
public partial class BwdifCudaClass
{
[JsonProperty("mode")]
public string Mode { get ; set ; }
[JsonPropertyName ("mode")]
public string? Mode { get ; set ; }
}
public partial class DeinterlaceQsvClass
{
[JsonProperty("mode")]
public string Mode { get ; set ; }
[JsonPropertyName ("mode")]
public string? Mode { get ; set ; }
}
public partial class DeinterlaceVaapiClass
{
[JsonProperty("mode")]
public string Mode { get ; set ; }
[JsonPropertyName ("mode")]
public string? Mode { get ; set ; }
}
public partial class LibplaceboClass
{
[JsonProperty("tonemapping")]
public string Tonemapping { get ; set ; }
[JsonPropertyName ("tonemapping")]
public string? Tonemapping { get ; set ; }
}
public partial class TonemapClass
{
[JsonProperty("tonemap")]
public string Tonemap { get ; set ; }
[JsonPropertyName ("tonemap")]
public string? Tonemap { get ; set ; }
}
public partial class TonemapOpenclClass
{
[JsonProperty("tonemap")]
public string Tonemap { get ; set ; }
[JsonPropertyName ("tonemap")]
public string? Tonemap { get ; set ; }
}
public partial class W3FdifClass
{
[JsonProperty("mode")]
public string Mode { get ; set ; }
[JsonPropertyName ("mode")]
public string? Mode { get ; set ; }
}
public partial class YadifClass
{
[JsonProperty("mode")]
public string Mode { get ; set ; }
[JsonPropertyName ("mode")]
public string? Mode { get ; set ; }
}
public partial class YadifCudaClass
{
[JsonProperty("mode")]
public string Mode { get ; set ; }
[JsonPropertyName ("mode")]
public string? Mode { get ; set ; }
}
public partial class Playout
{
[JsonProperty("folder")]
[JsonPropertyName ("folder")]
public string Folder { get ; set ; }
/// <summary>
/// RFC3339 formatted date/time, e.g. 2026-04-13T00:24:21.527-05:00
/// </summary>
[JsonProperty("virtual_start")]
public string VirtualStart { get ; set ; }
[JsonPropertyName ("virtual_start")]
public string? VirtualStart { get ; set ; }
}
public enum AudioFormat { Aac , Ac3 } ;
@ -257,21 +273,19 @@ namespace ErsatzTV.Core.Next.Config
@@ -257,21 +273,19 @@ namespace ErsatzTV.Core.Next.Config
public partial class ChannelConfig
{
public static ChannelConfig FromJson ( string json ) = > JsonConvert . DeserializeObject < ChannelConfig > ( json , ErsatzTV . Core . Next . Config . Converter . Settings ) ;
public static ChannelConfig FromJson ( string json ) = > JsonSerializer . Deserialize < ChannelConfig > ( json , ErsatzTV . Core . Next . Config . Converter . Settings ) ;
}
public static class Serialize
{
public static string ToJson ( this ChannelConfig self ) = > JsonConvert . SerializeObject ( self , ErsatzTV . Core . Next . Config . Converter . Settings ) ;
public static string ToJson ( this ChannelConfig self ) = > JsonSerializer . Serialize ( self , ErsatzTV . Core . Next . Config . Converter . Settings ) ;
}
internal static class Converter
{
public static readonly JsonSerializerSettings Settings = new JsonSerializerSettings
public static readonly JsonSerializerOptions Settings = new ( JsonSerializerDefaults . General )
{
NullValueHandling = NullValueHandling . Ignore ,
MetadataPropertyHandling = MetadataPropertyHandling . Ignore ,
DateParseHandling = DateParseHandling . None ,
DefaultIgnoreCondition = JsonIgnoreCondition . WhenWritingNull ,
Converters =
{
AudioFormatConverter . Singleton ,
@ -280,19 +294,20 @@ namespace ErsatzTV.Core.Next.Config
@@ -280,19 +294,20 @@ namespace ErsatzTV.Core.Next.Config
VideoFormatConverter . Singleton ,
ScalingModeConverter . Singleton ,
VaapiDriverEnumConverter . Singleton ,
new IsoDateTimeConverter { DateTimeStyles = DateTimeStyles . AssumeUniversal }
new DateOnlyConverter ( ) ,
new TimeOnlyConverter ( ) ,
IsoDateTimeOffsetConverter . Singleton
} ,
} ;
}
internal class AudioFormatConverter : JsonConverter
internal class AudioFormatConverter : JsonConverter < AudioFormat >
{
public override bool CanConvert ( Type t ) = > t = = typeof ( AudioFormat ) | | t = = typeof ( AudioFormat ? ) ;
public override bool CanConvert ( Type t ) = > t = = typeof ( AudioFormat ) ;
public override object ReadJson ( JsonReader reader , Type t , object existingValue , JsonSerializer serializer )
public override AudioFormat Read ( ref Utf8JsonReader reader , Type typeToConvert , JsonSerializerOptions option s)
{
if ( reader . TokenType = = JsonToken . Null ) return null ;
var value = serializer . Deserialize < string > ( reader ) ;
var value = reader . GetString ( ) ;
switch ( value )
{
case "aac" :
@ -303,21 +318,15 @@ namespace ErsatzTV.Core.Next.Config
@@ -303,21 +318,15 @@ namespace ErsatzTV.Core.Next.Config
throw new Exception ( "Cannot unmarshal type AudioFormat" ) ;
}
public override void WriteJson ( JsonWriter writer , object untypedV alue, JsonSerializer serializer )
public override void Write ( Utf8 JsonWriter writer , AudioFormat v alue, JsonSerializerOptions option s)
{
if ( untypedValue = = null )
{
serializer . Serialize ( writer , null ) ;
return ;
}
var value = ( AudioFormat ) untypedValue ;
switch ( value )
{
case AudioFormat . Aac :
serializer . Serialize ( writer , "aac" ) ;
JsonSerializer . Serialize ( writer , "aac" , options ) ;
return ;
case AudioFormat . Ac3 :
serializer . Serialize ( writer , "ac3" ) ;
J sonS erializer. Serialize ( writer , "ac3" , options ) ;
return ;
}
throw new Exception ( "Cannot marshal type AudioFormat" ) ;
@ -326,14 +335,13 @@ namespace ErsatzTV.Core.Next.Config
@@ -326,14 +335,13 @@ namespace ErsatzTV.Core.Next.Config
public static readonly AudioFormatConverter Singleton = new AudioFormatConverter ( ) ;
}
internal class ModeConverter : JsonConverter
internal class ModeConverter : JsonConverter < Mode >
{
public override bool CanConvert ( Type t ) = > t = = typeof ( Mode ) | | t = = typeof ( Mode ? ) ;
public override bool CanConvert ( Type t ) = > t = = typeof ( Mode ) ;
public override object ReadJson ( JsonReader reader , Type t , object existingValue , JsonSerializer serializer )
public override Mode Read ( ref Utf8JsonReader reader , Type typeToConvert , JsonSerializerOptions option s)
{
if ( reader . TokenType = = JsonToken . Null ) return null ;
var value = serializer . Deserialize < string > ( reader ) ;
var value = reader . GetString ( ) ;
switch ( value )
{
case "burn" :
@ -344,21 +352,15 @@ namespace ErsatzTV.Core.Next.Config
@@ -344,21 +352,15 @@ namespace ErsatzTV.Core.Next.Config
throw new Exception ( "Cannot unmarshal type Mode" ) ;
}
public override void WriteJson ( JsonWriter writer , object untypedV alue, JsonSerializer serializer )
public override void Write ( Utf8 JsonWriter writer , Mode v alue, JsonSerializerOptions option s)
{
if ( untypedValue = = null )
{
serializer . Serialize ( writer , null ) ;
return ;
}
var value = ( Mode ) untypedValue ;
switch ( value )
{
case Mode . Burn :
serializer . Serialize ( writer , "burn" ) ;
JsonSerializer . Serialize ( writer , "burn" , options ) ;
return ;
case Mode . Convert :
serializer . Serialize ( writer , "convert" ) ;
J sonS erializer. Serialize ( writer , "convert" , options ) ;
return ;
}
throw new Exception ( "Cannot marshal type Mode" ) ;
@ -367,14 +369,13 @@ namespace ErsatzTV.Core.Next.Config
@@ -367,14 +369,13 @@ namespace ErsatzTV.Core.Next.Config
public static readonly ModeConverter Singleton = new ModeConverter ( ) ;
}
internal class AccelEnumConverter : JsonConverter
internal class AccelEnumConverter : JsonConverter < AccelEnum >
{
public override bool CanConvert ( Type t ) = > t = = typeof ( AccelEnum ) | | t = = typeof ( AccelEnum ? ) ;
public override bool CanConvert ( Type t ) = > t = = typeof ( AccelEnum ) ;
public override object ReadJson ( JsonReader reader , Type t , object existingValue , JsonSerializer serializer )
public override AccelEnum Read ( ref Utf8JsonReader reader , Type typeToConvert , JsonSerializerOptions option s)
{
if ( reader . TokenType = = JsonToken . Null ) return null ;
var value = serializer . Deserialize < string > ( reader ) ;
var value = reader . GetString ( ) ;
switch ( value )
{
case "amf" :
@ -395,36 +396,30 @@ namespace ErsatzTV.Core.Next.Config
@@ -395,36 +396,30 @@ namespace ErsatzTV.Core.Next.Config
throw new Exception ( "Cannot unmarshal type AccelEnum" ) ;
}
public override void WriteJson ( JsonWriter writer , object untypedV alue, JsonSerializer serializer )
public override void Write ( Utf8 JsonWriter writer , AccelEnum v alue, JsonSerializerOptions option s)
{
if ( untypedValue = = null )
{
serializer . Serialize ( writer , null ) ;
return ;
}
var value = ( AccelEnum ) untypedValue ;
switch ( value )
{
case AccelEnum . Amf :
serializer . Serialize ( writer , "amf" ) ;
JsonSerializer . Serialize ( writer , "amf" , options ) ;
return ;
case AccelEnum . Cuda :
serializer . Serialize ( writer , "cuda" ) ;
J sonS erializer. Serialize ( writer , "cuda" , options ) ;
return ;
case AccelEnum . Qsv :
serializer . Serialize ( writer , "qsv" ) ;
J sonS erializer. Serialize ( writer , "qsv" , options ) ;
return ;
case AccelEnum . Rkmpp :
serializer . Serialize ( writer , "rkmpp" ) ;
J sonS erializer. Serialize ( writer , "rkmpp" , options ) ;
return ;
case AccelEnum . Vaapi :
serializer . Serialize ( writer , "vaapi" ) ;
J sonS erializer. Serialize ( writer , "vaapi" , options ) ;
return ;
case AccelEnum . Videotoolbox :
serializer . Serialize ( writer , "videotoolbox" ) ;
J sonS erializer. Serialize ( writer , "videotoolbox" , options ) ;
return ;
case AccelEnum . Vulkan :
serializer . Serialize ( writer , "vulkan" ) ;
J sonS erializer. Serialize ( writer , "vulkan" , options ) ;
return ;
}
throw new Exception ( "Cannot marshal type AccelEnum" ) ;
@ -433,14 +428,13 @@ namespace ErsatzTV.Core.Next.Config
@@ -433,14 +428,13 @@ namespace ErsatzTV.Core.Next.Config
public static readonly AccelEnumConverter Singleton = new AccelEnumConverter ( ) ;
}
internal class VideoFormatConverter : JsonConverter
internal class VideoFormatConverter : JsonConverter < VideoFormat >
{
public override bool CanConvert ( Type t ) = > t = = typeof ( VideoFormat ) | | t = = typeof ( VideoFormat ? ) ;
public override bool CanConvert ( Type t ) = > t = = typeof ( VideoFormat ) ;
public override object ReadJson ( JsonReader reader , Type t , object existingValue , JsonSerializer serializer )
public override VideoFormat Read ( ref Utf8JsonReader reader , Type typeToConvert , JsonSerializerOptions option s)
{
if ( reader . TokenType = = JsonToken . Null ) return null ;
var value = serializer . Deserialize < string > ( reader ) ;
var value = reader . GetString ( ) ;
switch ( value )
{
case "h264" :
@ -451,21 +445,15 @@ namespace ErsatzTV.Core.Next.Config
@@ -451,21 +445,15 @@ namespace ErsatzTV.Core.Next.Config
throw new Exception ( "Cannot unmarshal type VideoFormat" ) ;
}
public override void WriteJson ( JsonWriter writer , object untypedV alue, JsonSerializer serializer )
public override void Write ( Utf8 JsonWriter writer , VideoFormat v alue, JsonSerializerOptions option s)
{
if ( untypedValue = = null )
{
serializer . Serialize ( writer , null ) ;
return ;
}
var value = ( VideoFormat ) untypedValue ;
switch ( value )
{
case VideoFormat . H264 :
serializer . Serialize ( writer , "h264" ) ;
JsonSerializer . Serialize ( writer , "h264" , options ) ;
return ;
case VideoFormat . Hevc :
serializer . Serialize ( writer , "hevc" ) ;
J sonS erializer. Serialize ( writer , "hevc" , options ) ;
return ;
}
throw new Exception ( "Cannot marshal type VideoFormat" ) ;
@ -474,14 +462,13 @@ namespace ErsatzTV.Core.Next.Config
@@ -474,14 +462,13 @@ namespace ErsatzTV.Core.Next.Config
public static readonly VideoFormatConverter Singleton = new VideoFormatConverter ( ) ;
}
internal class ScalingModeConverter : JsonConverter
internal class ScalingModeConverter : JsonConverter < ScalingMode >
{
public override bool CanConvert ( Type t ) = > t = = typeof ( ScalingMode ) | | t = = typeof ( ScalingMode ? ) ;
public override bool CanConvert ( Type t ) = > t = = typeof ( ScalingMode ) ;
public override object ReadJson ( JsonReader reader , Type t , object existingValue , JsonSerializer serializer )
public override ScalingMode Read ( ref Utf8JsonReader reader , Type typeToConvert , JsonSerializerOptions option s)
{
if ( reader . TokenType = = JsonToken . Null ) return null ;
var value = serializer . Deserialize < string > ( reader ) ;
var value = reader . GetString ( ) ;
switch ( value )
{
case "crop" :
@ -494,24 +481,18 @@ namespace ErsatzTV.Core.Next.Config
@@ -494,24 +481,18 @@ namespace ErsatzTV.Core.Next.Config
throw new Exception ( "Cannot unmarshal type ScalingMode" ) ;
}
public override void WriteJson ( JsonWriter writer , object untypedV alue, JsonSerializer serializer )
public override void Write ( Utf8 JsonWriter writer , ScalingMode v alue, JsonSerializerOptions option s)
{
if ( untypedValue = = null )
{
serializer . Serialize ( writer , null ) ;
return ;
}
var value = ( ScalingMode ) untypedValue ;
switch ( value )
{
case ScalingMode . Crop :
serializer . Serialize ( writer , "crop" ) ;
JsonSerializer . Serialize ( writer , "crop" , options ) ;
return ;
case ScalingMode . ScaleAndPad :
serializer . Serialize ( writer , "scale_and_pad" ) ;
J sonS erializer. Serialize ( writer , "scale_and_pad" , options ) ;
return ;
case ScalingMode . Stretch :
serializer . Serialize ( writer , "stretch" ) ;
J sonS erializer. Serialize ( writer , "stretch" , options ) ;
return ;
}
throw new Exception ( "Cannot marshal type ScalingMode" ) ;
@ -520,14 +501,13 @@ namespace ErsatzTV.Core.Next.Config
@@ -520,14 +501,13 @@ namespace ErsatzTV.Core.Next.Config
public static readonly ScalingModeConverter Singleton = new ScalingModeConverter ( ) ;
}
internal class VaapiDriverEnumConverter : JsonConverter
internal class VaapiDriverEnumConverter : JsonConverter < VaapiDriverEnum >
{
public override bool CanConvert ( Type t ) = > t = = typeof ( VaapiDriverEnum ) | | t = = typeof ( VaapiDriverEnum ? ) ;
public override bool CanConvert ( Type t ) = > t = = typeof ( VaapiDriverEnum ) ;
public override object ReadJson ( JsonReader reader , Type t , object existingValue , JsonSerializer serializer )
public override VaapiDriverEnum Read ( ref Utf8JsonReader reader , Type typeToConvert , JsonSerializerOptions option s)
{
if ( reader . TokenType = = JsonToken . Null ) return null ;
var value = serializer . Deserialize < string > ( reader ) ;
var value = reader . GetString ( ) ;
switch ( value )
{
case "i965" :
@ -540,24 +520,18 @@ namespace ErsatzTV.Core.Next.Config
@@ -540,24 +520,18 @@ namespace ErsatzTV.Core.Next.Config
throw new Exception ( "Cannot unmarshal type VaapiDriverEnum" ) ;
}
public override void WriteJson ( JsonWriter writer , object untypedV alue, JsonSerializer serializer )
public override void Write ( Utf8 JsonWriter writer , VaapiDriverEnum v alue, JsonSerializerOptions option s)
{
if ( untypedValue = = null )
{
serializer . Serialize ( writer , null ) ;
return ;
}
var value = ( VaapiDriverEnum ) untypedValue ;
switch ( value )
{
case VaapiDriverEnum . I965 :
serializer . Serialize ( writer , "i965" ) ;
JsonSerializer . Serialize ( writer , "i965" , options ) ;
return ;
case VaapiDriverEnum . Ihd :
serializer . Serialize ( writer , "ihd" ) ;
J sonS erializer. Serialize ( writer , "ihd" , options ) ;
return ;
case VaapiDriverEnum . Radeonsi :
serializer . Serialize ( writer , "radeonsi" ) ;
J sonS erializer. Serialize ( writer , "radeonsi" , options ) ;
return ;
}
throw new Exception ( "Cannot marshal type VaapiDriverEnum" ) ;
@ -565,4 +539,118 @@ namespace ErsatzTV.Core.Next.Config
@@ -565,4 +539,118 @@ namespace ErsatzTV.Core.Next.Config
public static readonly VaapiDriverEnumConverter Singleton = new VaapiDriverEnumConverter ( ) ;
}
public class DateOnlyConverter : JsonConverter < DateOnly >
{
private readonly string serializationFormat ;
public DateOnlyConverter ( ) : this ( null ) { }
public DateOnlyConverter ( string? serializationFormat )
{
this . serializationFormat = serializationFormat ? ? "yyyy-MM-dd" ;
}
public override DateOnly Read ( ref Utf8JsonReader reader , Type typeToConvert , JsonSerializerOptions options )
{
var value = reader . GetString ( ) ;
return DateOnly . Parse ( value ! ) ;
}
public override void Write ( Utf8JsonWriter writer , DateOnly value , JsonSerializerOptions options )
= > writer . WriteStringValue ( value . ToString ( serializationFormat ) ) ;
}
public class TimeOnlyConverter : JsonConverter < TimeOnly >
{
private readonly string serializationFormat ;
public TimeOnlyConverter ( ) : this ( null ) { }
public TimeOnlyConverter ( string? serializationFormat )
{
this . serializationFormat = serializationFormat ? ? "HH:mm:ss.fff" ;
}
public override TimeOnly Read ( ref Utf8JsonReader reader , Type typeToConvert , JsonSerializerOptions options )
{
var value = reader . GetString ( ) ;
return TimeOnly . Parse ( value ! ) ;
}
public override void Write ( Utf8JsonWriter writer , TimeOnly value , JsonSerializerOptions options )
= > writer . WriteStringValue ( value . ToString ( serializationFormat ) ) ;
}
internal class IsoDateTimeOffsetConverter : JsonConverter < DateTimeOffset >
{
public override bool CanConvert ( Type t ) = > t = = typeof ( DateTimeOffset ) ;
private const string DefaultDateTimeFormat = "yyyy'-'MM'-'dd'T'HH':'mm':'ss.FFFFFFFK" ;
private DateTimeStyles _d ateTimeStyles = DateTimeStyles . RoundtripKind ;
private string? _d ateTimeFormat ;
private CultureInfo ? _ culture ;
public DateTimeStyles DateTimeStyles
{
get = > _d ateTimeStyles ;
set = > _d ateTimeStyles = value ;
}
public string? DateTimeFormat
{
get = > _d ateTimeFormat ? ? string . Empty ;
set = > _d ateTimeFormat = ( string . IsNullOrEmpty ( value ) ) ? null : value ;
}
public CultureInfo Culture
{
get = > _ culture ? ? CultureInfo . CurrentCulture ;
set = > _ culture = value ;
}
public override void Write ( Utf8JsonWriter writer , DateTimeOffset value , JsonSerializerOptions options )
{
string text ;
if ( ( _d ateTimeStyles & DateTimeStyles . AdjustToUniversal ) = = DateTimeStyles . AdjustToUniversal
| | ( _d ateTimeStyles & DateTimeStyles . AssumeUniversal ) = = DateTimeStyles . AssumeUniversal )
{
value = value . ToUniversalTime ( ) ;
}
text = value . ToString ( _d ateTimeFormat ? ? DefaultDateTimeFormat , Culture ) ;
writer . WriteStringValue ( text ) ;
}
public override DateTimeOffset Read ( ref Utf8JsonReader reader , Type typeToConvert , JsonSerializerOptions options )
{
string? dateText = reader . GetString ( ) ;
if ( string . IsNullOrEmpty ( dateText ) = = false )
{
if ( ! string . IsNullOrEmpty ( _d ateTimeFormat ) )
{
return DateTimeOffset . ParseExact ( dateText , _d ateTimeFormat , Culture , _d ateTimeStyles ) ;
}
else
{
return DateTimeOffset . Parse ( dateText , Culture , _d ateTimeStyles ) ;
}
}
else
{
return default ( DateTimeOffset ) ;
}
}
public static readonly IsoDateTimeOffsetConverter Singleton = new IsoDateTimeOffsetConverter ( ) ;
}
}
#pragma warning restore CS8618
#pragma warning restore CS8601
#pragma warning restore CS8602
#pragma warning restore CS8603