diff --git a/examples/Kentico.Xperience.UMT.Examples/Samples/ContentItemSimplifiedSamples.cs b/examples/Kentico.Xperience.UMT.Examples/Samples/ContentItemSimplifiedSamples.cs index 482a167..eeaf787 100644 --- a/examples/Kentico.Xperience.UMT.Examples/Samples/ContentItemSimplifiedSamples.cs +++ b/examples/Kentico.Xperience.UMT.Examples/Samples/ContentItemSimplifiedSamples.cs @@ -303,7 +303,7 @@ public static ContentItemSimplifiedModel SampleArticleSubPageContentItemSimplifi ["EventText"] = "en-US Event sample 2024 (reusable)", ["EventDate"] = new DateTime(2024,1,1,0,0,0,0, DateTimeKind.Utc), ["EventRecurrentYearly"] = true, - ["EventTeaser"] = new AssetDataSource + ["EventTeaser"] = new AssetDataSource { ContentItemGuid = SampleEvent2024ContentItemGuid, Identifier = new Guid("2A645BAB-F2DC-4B94-A226-FD680B9DF901"), diff --git a/src/Kentico.Xperience.UMT/InfoAdapter/ContentItemSimplifiedAdapter.cs b/src/Kentico.Xperience.UMT/InfoAdapter/ContentItemSimplifiedAdapter.cs index 51cee8a..e8efbd8 100644 --- a/src/Kentico.Xperience.UMT/InfoAdapter/ContentItemSimplifiedAdapter.cs +++ b/src/Kentico.Xperience.UMT/InfoAdapter/ContentItemSimplifiedAdapter.cs @@ -460,21 +460,21 @@ private static IEnumerable UnpackReusableFieldSchemas(IEnumerable private static bool IsImageAsset(object? value) { - if (value is JsonElement { ValueKind: JsonValueKind.Object } element && element.GetProperty(AssetSource.DISCRIMINATOR_PROPERTY).GetString() is { }) + switch (value) { - var assetSource = element.Deserialize(); - if (assetSource is not null) + case AssetSource assetSource: { return ImageHelper.IsImage(assetSource.InferExtension()); } - else + case JsonElement { ValueKind: JsonValueKind.Object } jsonElement when jsonElement.GetProperty(AssetSource.DISCRIMINATOR_PROPERTY).GetString() is { }: { - throw new InvalidOperationException($"JSON object with property {AssetSource.DISCRIMINATOR_PROPERTY} cannot be deserialized"); + var asset = jsonElement.Deserialize() ?? throw new InvalidOperationException($"JSON object with property {AssetSource.DISCRIMINATOR_PROPERTY} cannot be deserialized"); + return ImageHelper.IsImage(asset.InferExtension()); + } + default: + { + return false; } - } - else - { - return false; } } }