Renamed SharedSerializationContext to SerializationContext. Added error handling and no build cache functionality
This commit is contained in:
77
Moonlight.Shared/Http/SerializationContext.cs
Normal file
77
Moonlight.Shared/Http/SerializationContext.cs
Normal file
@@ -0,0 +1,77 @@
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
using Moonlight.Shared.Http.Events;
|
||||
using Moonlight.Shared.Http.Requests.Admin.ApiKeys;
|
||||
using Moonlight.Shared.Http.Requests.Admin.ContainerHelper;
|
||||
using Moonlight.Shared.Http.Requests.Admin.Roles;
|
||||
using Moonlight.Shared.Http.Requests.Admin.Themes;
|
||||
using Moonlight.Shared.Http.Requests.Admin.Users;
|
||||
using Moonlight.Shared.Http.Responses;
|
||||
using Moonlight.Shared.Http.Responses.Admin;
|
||||
using Moonlight.Shared.Http.Responses.Admin.ApiKeys;
|
||||
using Moonlight.Shared.Http.Responses.Admin.Auth;
|
||||
using Moonlight.Shared.Http.Responses.Admin.Themes;
|
||||
using Moonlight.Shared.Http.Responses.Admin.Users;
|
||||
|
||||
namespace Moonlight.Shared.Http;
|
||||
|
||||
// Users
|
||||
[JsonSerializable(typeof(CreateUserDto))]
|
||||
[JsonSerializable(typeof(UpdateUserDto))]
|
||||
[JsonSerializable(typeof(PagedData<UserDto>))]
|
||||
[JsonSerializable(typeof(UserDto))]
|
||||
|
||||
// Auth
|
||||
[JsonSerializable(typeof(ClaimDto[]))]
|
||||
[JsonSerializable(typeof(SchemeDto[]))]
|
||||
|
||||
// System
|
||||
[JsonSerializable(typeof(DiagnoseResultDto[]))]
|
||||
[JsonSerializable(typeof(SystemInfoDto))]
|
||||
|
||||
// Roles
|
||||
[JsonSerializable(typeof(CreateRoleDto))]
|
||||
[JsonSerializable(typeof(UpdateRoleDto))]
|
||||
[JsonSerializable(typeof(PagedData<RoleDto>))]
|
||||
[JsonSerializable(typeof(RoleDto))]
|
||||
|
||||
// API Keys
|
||||
[JsonSerializable(typeof(CreateApiKeyDto))]
|
||||
[JsonSerializable(typeof(UpdateApiKeyDto))]
|
||||
[JsonSerializable(typeof(PagedData<ApiKeyDto>))]
|
||||
[JsonSerializable(typeof(ApiKeyDto))]
|
||||
|
||||
// Themes
|
||||
[JsonSerializable(typeof(CreateThemeDto))]
|
||||
[JsonSerializable(typeof(UpdateThemeDto))]
|
||||
[JsonSerializable(typeof(PagedData<ThemeDto>))]
|
||||
[JsonSerializable(typeof(ThemeDto))]
|
||||
|
||||
// Events
|
||||
[JsonSerializable(typeof(RebuildEventDto))]
|
||||
|
||||
// Container Helper
|
||||
[JsonSerializable(typeof(ContainerHelperStatusDto))]
|
||||
[JsonSerializable(typeof(RequestRebuildDto))]
|
||||
[JsonSerializable(typeof(SetVersionDto))]
|
||||
|
||||
// Misc
|
||||
[JsonSerializable(typeof(ProblemDetails))]
|
||||
public partial class SerializationContext : JsonSerializerContext
|
||||
{
|
||||
private static JsonSerializerOptions? InternalTunedOptions;
|
||||
|
||||
public static JsonSerializerOptions TunedOptions
|
||||
{
|
||||
get
|
||||
{
|
||||
if (InternalTunedOptions != null)
|
||||
return InternalTunedOptions;
|
||||
|
||||
InternalTunedOptions = new JsonSerializerOptions(JsonSerializerDefaults.Web);
|
||||
InternalTunedOptions.TypeInfoResolverChain.Add(Default);
|
||||
|
||||
return InternalTunedOptions;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user