-
Notifications
You must be signed in to change notification settings - Fork 832
Expand file tree
/
Copy pathIconStoreJson.cs
More file actions
25 lines (21 loc) · 887 Bytes
/
IconStoreJson.cs
File metadata and controls
25 lines (21 loc) · 887 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
using System.Text.Json;
using System.Text.Json.Serialization;
using System.Text.Json.Serialization.Metadata;
namespace UniGetUI.Core.IconEngine;
internal static class IconStoreJson
{
public static IconScreenshotDatabase_v2 DeserializeIconDatabase(string json)
{
return JsonSerializer.Deserialize(json, GetTypeInfo<IconScreenshotDatabase_v2>());
}
private static JsonTypeInfo<T> GetTypeInfo<T>()
{
return (JsonTypeInfo<T>?)IconStoreJsonContext.Default.GetTypeInfo(typeof(T))
?? throw new InvalidOperationException(
$"Icon store JSON metadata for {typeof(T).FullName} was not generated."
);
}
}
[JsonSourceGenerationOptions(AllowTrailingCommas = true, WriteIndented = true)]
[JsonSerializable(typeof(IconScreenshotDatabase_v2))]
internal sealed partial class IconStoreJsonContext : JsonSerializerContext;