mirror of
https://git.lewd.wtf/PGR/ascnet
synced 2025-12-13 12:34:38 +01:00
table reader v1
This commit is contained in:
32
AscNet.Common/Util/TableReader.cs
Normal file
32
AscNet.Common/Util/TableReader.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
using AscNet.Logging;
|
||||
|
||||
namespace AscNet.Common.Util
|
||||
{
|
||||
#pragma warning disable CS8618, CS8602 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
|
||||
public abstract class TableReader<TSelf, TScheme>
|
||||
{
|
||||
public List<TScheme> All { get; set; }
|
||||
private readonly Logger c = new(typeof(TableReader<TSelf, TScheme>), nameof(TableReader<TSelf, TScheme>), LogLevel.DEBUG, LogLevel.DEBUG);
|
||||
protected abstract string FilePath { get; }
|
||||
private static TSelf _instance;
|
||||
|
||||
public static TSelf Instance
|
||||
{
|
||||
get
|
||||
{
|
||||
_instance ??= Activator.CreateInstance<TSelf>();
|
||||
// ReSharper disable once ConditionIsAlwaysTrueOrFalseAccordingToNullableAPIContract
|
||||
if ((_instance as TableReader<TSelf, TScheme>).All == null)
|
||||
{
|
||||
(_instance as TableReader<TSelf, TScheme>).Load();
|
||||
(_instance as TableReader<TSelf, TScheme>).c.Debug($"{typeof(TSelf).Name} Excel Loaded From {(_instance as TableReader<TSelf, TScheme>).FilePath}");
|
||||
}
|
||||
|
||||
return _instance;
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract void Load();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user