27 lines
981 B
C#
27 lines
981 B
C#
using System.Text.Json;
|
|
|
|
namespace Flypaper.Web.Components.Pages.Dashboard;
|
|
|
|
internal sealed record WorldMapData(
|
|
double Width,
|
|
double Height,
|
|
IReadOnlyList<WorldMapCountry> Countries,
|
|
IReadOnlyList<WorldMapMarker> Markers)
|
|
{
|
|
private static readonly JsonSerializerOptions JsonOptions = new(JsonSerializerDefaults.Web);
|
|
|
|
public static WorldMapData Instance { get; } = Load();
|
|
|
|
private static WorldMapData Load()
|
|
{
|
|
using var stream = typeof(WorldMapData).Assembly.GetManifestResourceStream("Flypaper.Web.world-map.json")
|
|
?? throw new InvalidOperationException("Embedded world map is missing.");
|
|
return JsonSerializer.Deserialize<WorldMapData>(stream, JsonOptions)
|
|
?? throw new InvalidOperationException("Embedded world map is empty.");
|
|
}
|
|
}
|
|
|
|
internal sealed record WorldMapCountry(string? Code, string Name, string Path);
|
|
|
|
internal sealed record WorldMapMarker(string Code, string Name, double X, double Y);
|