forked from PGR/ascnet
1
0
Fork 0
ascnet/AscNet.Common/Util/TableReader.cs

33 lines
1.2 KiB
C#
Raw Normal View History

2023-10-18 08:49:36 +00:00
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; }
protected abstract string FilePath { get; }
2023-10-18 14:45:13 +00:00
private readonly Logger c = new(typeof(TableReader<TSelf, TScheme>), nameof(TableReader<TSelf, TScheme>), LogLevel.DEBUG, LogLevel.DEBUG);
2023-10-18 08:49:36 +00:00
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;
}
}
2023-10-18 14:45:13 +00:00
public abstract void Load();
2023-10-18 08:49:36 +00:00
}
}