Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions src/libs/Shotstack/Generated/Shotstack.JsonConverters.Asset.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,13 @@ public class AssetJsonConverter : global::System.Text.Json.Serialization.JsonCon
throw new global::System.InvalidOperationException($"Cannot get type info for {nameof(global::Shotstack.HtmlAsset)}");
html = global::System.Text.Json.JsonSerializer.Deserialize(ref reader, typeInfo);
}
global::Shotstack.Html5Asset? html5 = default;
if (discriminator?.Type == global::Shotstack.AssetDiscriminatorType.Html5)
{
var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::Shotstack.Html5Asset), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::Shotstack.Html5Asset> ??
throw new global::System.InvalidOperationException($"Cannot get type info for {nameof(global::Shotstack.Html5Asset)}");
html5 = global::System.Text.Json.JsonSerializer.Deserialize(ref reader, typeInfo);
}
global::Shotstack.TitleAsset? title = default;
if (discriminator?.Type == global::Shotstack.AssetDiscriminatorType.Title)
{
Expand Down Expand Up @@ -147,6 +154,8 @@ public class AssetJsonConverter : global::System.Text.Json.Serialization.JsonCon

html,

html5,

title,

shape,
Expand Down Expand Up @@ -226,6 +235,12 @@ public override void Write(
throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::Shotstack.HtmlAsset).Name}");
global::System.Text.Json.JsonSerializer.Serialize(writer, value.Html!, typeInfo);
}
else if (value.IsHtml5)
{
var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::Shotstack.Html5Asset), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::Shotstack.Html5Asset?> ??
throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::Shotstack.Html5Asset).Name}");
global::System.Text.Json.JsonSerializer.Serialize(writer, value.Html5!, typeInfo);
}
else if (value.IsTitle)
{
var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::Shotstack.TitleAsset), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::Shotstack.TitleAsset?> ??
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#nullable enable

namespace Shotstack.JsonConverters
{
/// <inheritdoc />
public sealed class Html5AssetTypeJsonConverter : global::System.Text.Json.Serialization.JsonConverter<global::Shotstack.Html5AssetType>
{
/// <inheritdoc />
public override global::Shotstack.Html5AssetType Read(
ref global::System.Text.Json.Utf8JsonReader reader,
global::System.Type typeToConvert,
global::System.Text.Json.JsonSerializerOptions options)
{
switch (reader.TokenType)
{
case global::System.Text.Json.JsonTokenType.String:
{
var stringValue = reader.GetString();
if (stringValue != null)
{
return global::Shotstack.Html5AssetTypeExtensions.ToEnum(stringValue) ?? default;
}

break;
}
case global::System.Text.Json.JsonTokenType.Number:
{
var numValue = reader.GetInt32();
return (global::Shotstack.Html5AssetType)numValue;
}
case global::System.Text.Json.JsonTokenType.Null:
{
return default(global::Shotstack.Html5AssetType);
}
default:
throw new global::System.ArgumentOutOfRangeException(nameof(reader));
}

return default;
}

/// <inheritdoc />
public override void Write(
global::System.Text.Json.Utf8JsonWriter writer,
global::Shotstack.Html5AssetType value,
global::System.Text.Json.JsonSerializerOptions options)
{
writer = writer ?? throw new global::System.ArgumentNullException(nameof(writer));

writer.WriteStringValue(global::Shotstack.Html5AssetTypeExtensions.ToValueString(value));
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#nullable enable

namespace Shotstack.JsonConverters
{
/// <inheritdoc />
public sealed class Html5AssetTypeNullableJsonConverter : global::System.Text.Json.Serialization.JsonConverter<global::Shotstack.Html5AssetType?>
{
/// <inheritdoc />
public override global::Shotstack.Html5AssetType? Read(
ref global::System.Text.Json.Utf8JsonReader reader,
global::System.Type typeToConvert,
global::System.Text.Json.JsonSerializerOptions options)
{
switch (reader.TokenType)
{
case global::System.Text.Json.JsonTokenType.String:
{
var stringValue = reader.GetString();
if (stringValue != null)
{
return global::Shotstack.Html5AssetTypeExtensions.ToEnum(stringValue);
}

break;
}
case global::System.Text.Json.JsonTokenType.Number:
{
var numValue = reader.GetInt32();
return (global::Shotstack.Html5AssetType)numValue;
}
case global::System.Text.Json.JsonTokenType.Null:
{
return default(global::Shotstack.Html5AssetType?);
}
default:
throw new global::System.ArgumentOutOfRangeException(nameof(reader));
}

return default;
}

/// <inheritdoc />
public override void Write(
global::System.Text.Json.Utf8JsonWriter writer,
global::Shotstack.Html5AssetType? value,
global::System.Text.Json.JsonSerializerOptions options)
{
writer = writer ?? throw new global::System.ArgumentNullException(nameof(writer));

if (value == null)
{
writer.WriteNullValue();
}
else
{
writer.WriteStringValue(global::Shotstack.Html5AssetTypeExtensions.ToValueString(value.Value));
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,10 @@ namespace Shotstack

typeof(global::Shotstack.JsonConverters.HtmlAssetPositionNullableJsonConverter),

typeof(global::Shotstack.JsonConverters.Html5AssetTypeJsonConverter),

typeof(global::Shotstack.JsonConverters.Html5AssetTypeNullableJsonConverter),

typeof(global::Shotstack.JsonConverters.TitleAssetTypeJsonConverter),

typeof(global::Shotstack.JsonConverters.TitleAssetTypeNullableJsonConverter),
Expand Down Expand Up @@ -391,6 +395,7 @@ namespace Shotstack
[global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Shotstack.CaptionAsset))]
[global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Shotstack.RichCaptionAsset))]
[global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Shotstack.HtmlAsset))]
[global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Shotstack.Html5Asset))]
[global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Shotstack.TitleAsset))]
[global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Shotstack.ShapeAsset))]
[global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Shotstack.SvgAsset))]
Expand Down Expand Up @@ -457,6 +462,7 @@ namespace Shotstack
[global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Shotstack.TextToSpeechAssetEffect), TypeInfoPropertyName = "TextToSpeechAssetEffect2")]
[global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Shotstack.HtmlAssetType), TypeInfoPropertyName = "HtmlAssetType2")]
[global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Shotstack.HtmlAssetPosition), TypeInfoPropertyName = "HtmlAssetPosition2")]
[global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Shotstack.Html5AssetType), TypeInfoPropertyName = "Html5AssetType2")]
[global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Shotstack.TitleAssetType), TypeInfoPropertyName = "TitleAssetType2")]
[global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Shotstack.TitleAssetStyle), TypeInfoPropertyName = "TitleAssetStyle2")]
[global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Shotstack.TitleAssetSize), TypeInfoPropertyName = "TitleAssetSize2")]
Expand Down
Loading