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 { public List All { get; set; } protected abstract string FilePath { get; } private readonly Logger c = new(typeof(TableReader), nameof(TableReader), LogLevel.DEBUG, LogLevel.DEBUG); private static TSelf _instance; public static TSelf Instance { get { _instance ??= Activator.CreateInstance(); // ReSharper disable once ConditionIsAlwaysTrueOrFalseAccordingToNullableAPIContract if ((_instance as TableReader).All == null) { (_instance as TableReader).Load(); (_instance as TableReader).c.Debug($"{typeof(TSelf).Name} Excel Loaded From {(_instance as TableReader).FilePath}"); } return _instance; } } public abstract void Load(); } }