add default serializer for AppVersion
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
using Newtonsoft.Json;
|
||||
using Pilz.Updating.Json;
|
||||
|
||||
namespace Pilz.Updating;
|
||||
|
||||
[JsonConverter(typeof(AppVersionStringJsonConverter))]
|
||||
public class AppVersion(Version version, int build, Channels channel)
|
||||
{
|
||||
// P r o p e r t i e s
|
||||
|
||||
@@ -3,8 +3,12 @@ using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace Pilz.Updating.Json;
|
||||
|
||||
public class AppVersionStringJsonConverter : JsonConverter
|
||||
public class AppVersionStringJsonConverter(bool serializeAsObject) : JsonConverter
|
||||
{
|
||||
public AppVersionStringJsonConverter() : this(false)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Writes the JSON representation of the object.
|
||||
/// </summary>
|
||||
@@ -19,7 +23,7 @@ public class AppVersionStringJsonConverter : JsonConverter
|
||||
return;
|
||||
}
|
||||
|
||||
if (value is not AppVersion appVersion)
|
||||
if (serializeAsObject || value is not AppVersion appVersion)
|
||||
writer.WriteValue(value);
|
||||
else
|
||||
writer.WriteValue(appVersion.ToString());
|
||||
|
||||
Reference in New Issue
Block a user