table reader v1

This commit is contained in:
rfi
2023-10-18 15:49:36 +07:00
parent 8ebfb0df9a
commit c00ea3bd2c
2642 changed files with 211094 additions and 3 deletions

View File

@@ -8,8 +8,15 @@
<ItemGroup>
<PackageReference Include="Config.Net" Version="5.1.5" />
<PackageReference Include="CsvHelper" Version="30.0.1" />
<PackageReference Include="MessagePack" Version="2.4.59" />
<PackageReference Include="MongoDB.Driver" Version="2.21.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="../AscNet.Table/AscNet.Table.csproj"
OutputItemType="Analyzer"
ReferenceOutputAssembly="false" />
<AdditionalFiles Include="../Resources/table/**" />
<ProjectReference Include="..\AscNet.Logging\AscNet.Logging.csproj" />
</ItemGroup>
</Project>

View File

@@ -6,7 +6,7 @@ namespace AscNet.Common
public static class Common
{
public static readonly IConfig config;
public static readonly MongoClient mongoClient;
private static readonly MongoClient mongoClient;
public static readonly IMongoDatabase db;
static Common()

View 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();
}
}