-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUpdater.cs
More file actions
33 lines (27 loc) · 961 Bytes
/
Updater.cs
File metadata and controls
33 lines (27 loc) · 961 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
using System.Text.Json;
using System.Text.Json.Serialization;
using api.Models.FiveE;
namespace api
{
public class Updater(ILogger<Updater> logger, string spellPath)
{
private async Task<List<Spell>> FetchSpells()
{
logger.LogInformation($"Fetching spells from {spellPath}");
var txt = await File.ReadAllTextAsync(spellPath);
logger.LogInformation($"Read {txt.Length} chars from {spellPath}");
var spellList = JsonSerializer.Deserialize<SpellList>(txt);
if (spellList is null)
{
logger.LogCritical("Zero spells found");
throw new Exception("Zero spells found");
}
logger.LogInformation($"Fetched {spellList.Spell.Count} spells from {spellPath}");
return spellList.Spell;
}
public async Task RunAsync()
{
var spells = await FetchSpells();
}
}
}