using System.Reflection; using System.Text.Json; using System.Text.Json.Nodes; namespace XFEEliteDangerous.Core; public static class BundledData { private static readonly Lazy catalog = new(() => Read("catalog.json")?.Deserialize(Wire.Json) ?? []); public static IReadOnlyList Catalog => catalog.Value; private static readonly Lazy materials=new(()=>Read("native-materials.json")?.Deserialize(Wire.Json)??[]); public static IReadOnlyList NativeMaterials=>materials.Value; private static JsonNode? Read(string name) { var assembly = typeof(BundledData).Assembly; var resource = assembly.GetManifestResourceNames().FirstOrDefault(x => x.EndsWith("." + name, StringComparison.Ordinal)); if (resource is null) return null; using var stream = assembly.GetManifestResourceStream(resource)!; return JsonNode.Parse(stream); } }