sa/Stars Assistant/Services/CSVDataLoader.cs

42 lines
1.1 KiB
C#

using System;
using System.IO;
using System.Reactive.Linq;
using Splat;
using StarsAssistant.Helpers;
namespace StarsAssistant.Services;
public class CSVDataLoader
{
/// <summary>
/// Reference to the game metadata, retrieved by DI
/// </summary>
protected Services.Game Game = Locator.Current.GetService<Services.Game>()!;
public void CSVDataLoader()
{
}
public void StartPlanetCSVWatcher()
{
// TODO: which scheduler for Throttle?
var watcher = FsWatcher
.ObserveFileSystem(Game.GamePath, new string[] { Game.PlanetFileSearchPattern });
.ThrottleAndDistinct(2);
/*
watcher.Subscribe(x =>
{
Console.WriteLine($"{DateTime.Now.ToLongTimeString()} got {x.Count()} events:");
foreach (var fsEvent in x)
{
Console.WriteLine($"{DateTime.Now.ToLongTimeString()} {i++} {fsEvent.FullPath} - {fsEvent.ChangeType}");
}
});
*/
}
}