to rename
This commit is contained in:
20
apps/backend/Universe/Bootstrap/SystemTemplateLoader.cs
Normal file
20
apps/backend/Universe/Bootstrap/SystemTemplateLoader.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using System.Text.Json;
|
||||
using Microsoft.Extensions.Options;
|
||||
|
||||
namespace SpaceGame.Api.Universe.Bootstrap;
|
||||
|
||||
public sealed class SystemTemplateLoader(IOptions<StaticDataOptions> staticDataOptions)
|
||||
{
|
||||
private readonly JsonSerializerOptions _jsonOptions = new()
|
||||
{
|
||||
PropertyNameCaseInsensitive = true,
|
||||
};
|
||||
|
||||
internal List<SolarSystemDefinition> Load()
|
||||
{
|
||||
var path = Path.Combine(staticDataOptions.Value.DataRoot, "systems.json");
|
||||
var json = File.ReadAllText(path);
|
||||
return JsonSerializer.Deserialize<List<SolarSystemDefinition>>(json, _jsonOptions)
|
||||
?? throw new InvalidOperationException("Unable to read systems.json.");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user