TRX/tools/installer/TRX_InstallerLib/Utils/JsonUtils.cs
lahm86 e16fcda94b tools/installer: create common installer library
This creates a generic common installer WPF library for both games.
2025-03-30 12:34:54 +01:00

31 lines
932 B
C#

using Newtonsoft.Json.Linq;
using System.IO;
namespace TRX_InstallerLib.Utils;
public static class JsonUtils
{
public static JObject? LoadEmbeddedResource(string path)
{
// Try to locate the data in this assembly first, then merge it
// with the same in the entry assembly if relevant.
JObject? data = null;
if (AssemblyUtils.ResourceExists(path, true))
{
using Stream stream = AssemblyUtils.GetResourceStream(path, true);
using StreamReader reader = new(stream);
data = JObject.Parse(reader.ReadToEnd());
}
if (AssemblyUtils.ResourceExists(path, false))
{
data ??= new();
using Stream stream = AssemblyUtils.GetResourceStream(path, false);
using StreamReader reader = new(stream);
data.Merge(JObject.Parse(reader.ReadToEnd()));
}
return data;
}
}