using Newtonsoft.Json; namespace Common.Utils.ExcelReader { #pragma warning disable CS8618, CS8602 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable. public abstract class BaseExcelReader { public Scheme[] All { get; set; } private readonly Logger c = new("Factory", ConsoleColor.Yellow); public abstract string FileName { get; } private static Self Instance; public static Self GetInstance() { Instance ??= Activator.CreateInstance(); if ((Instance as BaseExcelReader).All == null) { (Instance as BaseExcelReader).Load(); if((int)Global.config.VerboseLevel > 1) (Instance as BaseExcelReader).c.Log($"{typeof(Self).Name} Excel Loaded From {(Instance as BaseExcelReader).FileName}"); } return Instance; } public void Load() { All = JsonConvert.DeserializeObject(File.ReadAllText($"Resources\\ExcelOutputAsset\\{FileName}")) ?? Array.Empty(); } #pragma warning restore CS8618, CS8602 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable. } }