Skip to content
This repository has been archived by the owner on May 30, 2024. It is now read-only.

Commit

Permalink
Merge pull request #44 from xpouyat/dev
Browse files Browse the repository at this point in the history
Fixes an issue with DateTime serialization for MK/IO REST API
  • Loading branch information
xpouyat authored Mar 8, 2024
2 parents 083db80 + 9ced27c commit a7602c0
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
22 changes: 21 additions & 1 deletion MK.IO/ConverterLE.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,28 @@ internal static class ConverterLE
//DateParseHandling = DateParseHandling.None,
Converters =
{
new IsoDateTimeConverter { DateTimeStyles = DateTimeStyles.AssumeUniversal }
new CustomDateTimeConverter()
//new IsoDateTimeConverter { DateTimeStyles = DateTimeStyles.AssumeUniversal }
},
};
}

// We limit the conversion of DateTime to the format "yyyy-MM-ddTHH:mm:ss.ffZ"
internal class CustomDateTimeConverter : JsonConverter
{
public override bool CanConvert(Type objectType)
{
return (objectType == typeof(DateTime)) || (objectType == typeof(DateTime?));
}

public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)

Check warning on line 34 in MK.IO/ConverterLE.cs

View workflow job for this annotation

GitHub Actions / run_test

Nullability of type of parameter 'existingValue' doesn't match overridden member (possibly because of nullability attributes).

Check warning on line 34 in MK.IO/ConverterLE.cs

View workflow job for this annotation

GitHub Actions / create_nuget

Nullability of type of parameter 'existingValue' doesn't match overridden member (possibly because of nullability attributes).

Check warning on line 34 in MK.IO/ConverterLE.cs

View workflow job for this annotation

GitHub Actions / create_nuget

Nullability of type of parameter 'existingValue' doesn't match overridden member (possibly because of nullability attributes).

Check warning on line 34 in MK.IO/ConverterLE.cs

View workflow job for this annotation

GitHub Actions / run_test

Nullability of type of parameter 'existingValue' doesn't match overridden member (possibly because of nullability attributes).
{
return DateTime.Parse(reader.Value.ToString());
}

public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)

Check warning on line 39 in MK.IO/ConverterLE.cs

View workflow job for this annotation

GitHub Actions / run_test

Nullability of type of parameter 'value' doesn't match overridden member (possibly because of nullability attributes).

Check warning on line 39 in MK.IO/ConverterLE.cs

View workflow job for this annotation

GitHub Actions / create_nuget

Nullability of type of parameter 'value' doesn't match overridden member (possibly because of nullability attributes).

Check warning on line 39 in MK.IO/ConverterLE.cs

View workflow job for this annotation

GitHub Actions / create_nuget

Nullability of type of parameter 'value' doesn't match overridden member (possibly because of nullability attributes).

Check warning on line 39 in MK.IO/ConverterLE.cs

View workflow job for this annotation

GitHub Actions / run_test

Nullability of type of parameter 'value' doesn't match overridden member (possibly because of nullability attributes).
{
writer.WriteValue(((DateTime)value).ToString("yyyy-MM-ddTHH:mm:ss.ffZ"));
}
}
}
6 changes: 3 additions & 3 deletions MK.IO/MK.IO.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@
<Description>A client library for MediaKind MK/IO.</Description>
<PackageLicenseFile>LICENSE.txt</PackageLicenseFile>
<PackageReadmeFile>README.md</PackageReadmeFile>
<Version>1.2.1</Version>
<Version>1.2.2</Version>
<RepositoryUrl>https://github.com/xpouyat/MK.IO</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<PackageProjectUrl>https://github.com/xpouyat/MK.IO/blob/master/README.md</PackageProjectUrl>
<AssemblyVersion>1.2.1.0</AssemblyVersion>
<FileVersion>1.2.1.0</FileVersion>
<AssemblyVersion>1.2.2.0</AssemblyVersion>
<FileVersion>1.2.2.0</FileVersion>
<Title>A client library for MediaKind MK/IO.</Title>
<IncludeSymbols>True</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
Expand Down

0 comments on commit a7602c0

Please sign in to comment.