mirror of
https://gitea.tendokyu.moe/Kayori/Medusa.net.git
synced 2026-09-27 17:28:01 +03:00
- Refactor handler dispatch to use a parsed GameModel instead of raw model strings (Handler.cs, HandlerService.cs, new GameModel.cs) - Add a Unity asset-extraction subsystem (Abstractions/Extractors/Unity) - Add WriteEventLogHandler, XrpcDouble serialization type - Rename EaCoin*Handler -> *EaCoinHandler for naming consistency - Add PIN/username update and forgot/reset password flows, with a console-logging IEmailSender until real email is wired up - Add a settings page and a theming pass (theme tokens, tailwind config) - Add plugin nav/route/UI-manifest frontend types
30 lines
1.2 KiB
C#
30 lines
1.2 KiB
C#
using System.IO;
|
|
using System.Text.Json;
|
|
using System.Threading;
|
|
using System.Threading.Tasks;
|
|
using Abstractions.Extractors.Unity.Helpers;
|
|
using AssetsTools.NET;
|
|
|
|
namespace Abstractions.Extractors.Unity.Services;
|
|
|
|
/// <summary>
|
|
/// JSON output for whatever ReflectionHelper.ToPlainObject() produces, plus the typetree-dump entry
|
|
/// point that most extractors fall back to.
|
|
/// </summary>
|
|
public static class ObjectSerializer
|
|
{
|
|
private static readonly JsonSerializerOptions Options = new() { WriteIndented = true };
|
|
|
|
/// <summary>Reads an object's full field tree into a plain object graph (Dictionary/List/primitives).</summary>
|
|
public static object? ReadTypeTree(AssetTypeValueField baseField) => ReflectionHelper.ToPlainObject(baseField);
|
|
|
|
public static async Task WriteJsonAsync(object? data, string path, CancellationToken cancellationToken = default)
|
|
{
|
|
await using var stream = File.Create(path);
|
|
await JsonSerializer.SerializeAsync(stream, data, Options, cancellationToken);
|
|
}
|
|
|
|
public static async Task WriteTextAsync(string content, string path, CancellationToken cancellationToken = default) =>
|
|
await File.WriteAllTextAsync(path, content, cancellationToken);
|
|
}
|