mirror of
https://github.com/MewoLab/AquaDX.git
synced 2026-02-15 02:57:26 +08:00
[RF] AquaMai configuration refactor (#82)
更新了配置文件格式,原有的配置文件将被自动无缝迁移,详情请见新的配置文件中的注释(例外:`SlideJudgeTweak` 不再默认启用) 旧配置文件将被重命名备份,如果更新到此版本遇到 Bug 请联系我们 Updated configuration file schema. The old config file will be migrated automatically and seamlessly. See the comments in the new configuration file for details. (Except for `SlideJudgeTweak` is no longer enabled by default) Your old configuration file will be renamed as a backup. If you encounter any bug with this version, please contact us.
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Release</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{DF1536F9-3B06-4463-B654-4CC3E708B610}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<RootNamespace>AquaMai.Config.Interfaces</RootNamespace>
|
||||
<AssemblyName>AquaMai.Config.Interfaces</AssemblyName>
|
||||
<TargetFramework>net472</TargetFramework>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<Deterministic>true</Deterministic>
|
||||
<LangVersion>12</LangVersion>
|
||||
<NoWarn>414</NoWarn>
|
||||
<AssemblySearchPaths>$(ProjectDir)../Libs/;$(AssemblySearchPaths)</AssemblySearchPaths>
|
||||
<OutputPath>$(ProjectDir)../Output/</OutputPath>
|
||||
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
|
||||
<EnableDefaultEmbeddedResourceItems>false</EnableDefaultEmbeddedResourceItems>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugSymbols>false</DebugSymbols>
|
||||
<DebugType>None</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<Prefer32Bit>false</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DefineConstants>DEBUG</DefineConstants>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Reference Include="mscorlib" />
|
||||
<Reference Include="System" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
28
AquaMai/AquaMai.Config.Interfaces/IConfig.cs
Normal file
28
AquaMai/AquaMai.Config.Interfaces/IConfig.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
using System;
|
||||
|
||||
namespace AquaMai.Config.Interfaces;
|
||||
|
||||
public interface IConfig
|
||||
{
|
||||
public interface IEntryState
|
||||
{
|
||||
public bool IsDefault { get; set; }
|
||||
public object DefaultValue { get; }
|
||||
public object Value { get; set; }
|
||||
}
|
||||
|
||||
public interface ISectionState
|
||||
{
|
||||
public bool IsDefault { get; set; }
|
||||
public bool DefaultEnabled { get; }
|
||||
public bool Enabled { get; set; }
|
||||
}
|
||||
|
||||
public IReflectionManager ReflectionManager { get; }
|
||||
|
||||
public ISectionState GetSectionState(IReflectionManager.ISection section);
|
||||
public ISectionState GetSectionState(Type type);
|
||||
public void SetSectionEnabled(IReflectionManager.ISection section, bool enabled);
|
||||
public IEntryState GetEntryState(IReflectionManager.IEntry entry);
|
||||
public void SetEntryValue(IReflectionManager.IEntry entry, object value);
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
namespace AquaMai.Config.Interfaces;
|
||||
|
||||
public interface IConfigMigrationManager
|
||||
{
|
||||
public IConfigView Migrate(IConfigView config);
|
||||
public string GetVersion(IConfigView config);
|
||||
}
|
||||
7
AquaMai/AquaMai.Config.Interfaces/IConfigParser.cs
Normal file
7
AquaMai/AquaMai.Config.Interfaces/IConfigParser.cs
Normal file
@@ -0,0 +1,7 @@
|
||||
namespace AquaMai.Config.Interfaces;
|
||||
|
||||
public interface IConfigParser
|
||||
{
|
||||
public void Parse(IConfig config, string tomlString);
|
||||
public void Parse(IConfig config, IConfigView configView);
|
||||
}
|
||||
13
AquaMai/AquaMai.Config.Interfaces/IConfigSerializer.cs
Normal file
13
AquaMai/AquaMai.Config.Interfaces/IConfigSerializer.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
namespace AquaMai.Config.Interfaces;
|
||||
|
||||
public interface IConfigSerializer
|
||||
{
|
||||
public record Options
|
||||
{
|
||||
public string Lang { get; init; }
|
||||
public bool IncludeBanner { get; init; }
|
||||
public bool OverrideLocaleValue { get; init; }
|
||||
}
|
||||
|
||||
public string Serialize(IConfig config);
|
||||
}
|
||||
9
AquaMai/AquaMai.Config.Interfaces/IConfigView.cs
Normal file
9
AquaMai/AquaMai.Config.Interfaces/IConfigView.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
namespace AquaMai.Config.Interfaces;
|
||||
|
||||
public interface IConfigView
|
||||
{
|
||||
public void SetValue(string path, object value);
|
||||
public T GetValueOrDefault<T>(string path, T defaultValue = default);
|
||||
public bool TryGetValue<T>(string path, out T resultValue);
|
||||
public string ToToml();
|
||||
}
|
||||
41
AquaMai/AquaMai.Config.Interfaces/IReflectionManager.cs
Normal file
41
AquaMai/AquaMai.Config.Interfaces/IReflectionManager.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
|
||||
namespace AquaMai.Config.Interfaces;
|
||||
|
||||
public interface IReflectionManager
|
||||
{
|
||||
public interface IEntry
|
||||
{
|
||||
public string Path { get; }
|
||||
public string Name { get; }
|
||||
public IReflectionField Field { get; }
|
||||
}
|
||||
|
||||
public interface ISection
|
||||
{
|
||||
public string Path { get; }
|
||||
public IReflectionType Type { get; }
|
||||
public List<IEntry> Entries { get; }
|
||||
}
|
||||
|
||||
public IEnumerable<ISection> Sections { get; }
|
||||
|
||||
public IEnumerable<IEntry> Entries { get; }
|
||||
|
||||
public bool ContainsSection(string path);
|
||||
|
||||
public bool TryGetSection(string path, out ISection section);
|
||||
|
||||
public bool TryGetSection(Type type, out ISection section);
|
||||
|
||||
public ISection GetSection(string path);
|
||||
|
||||
public ISection GetSection(Type type);
|
||||
|
||||
public bool ContainsEntry(string path);
|
||||
|
||||
public bool TryGetEntry(string path, out IEntry entry);
|
||||
|
||||
public IEntry GetEntry(string path);
|
||||
}
|
||||
30
AquaMai/AquaMai.Config.Interfaces/IReflectionProvider.cs
Normal file
30
AquaMai/AquaMai.Config.Interfaces/IReflectionProvider.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
|
||||
namespace AquaMai.Config.Interfaces;
|
||||
|
||||
public interface IReflectionField
|
||||
{
|
||||
public string Name { get; }
|
||||
public Type FieldType { get; }
|
||||
|
||||
public T GetCustomAttribute<T>() where T : Attribute;
|
||||
public object GetValue(object objIsNull);
|
||||
public void SetValue(object objIsNull, object value);
|
||||
}
|
||||
|
||||
public interface IReflectionType
|
||||
{
|
||||
public string FullName { get; }
|
||||
public string Namespace { get; }
|
||||
|
||||
public T GetCustomAttribute<T>() where T : Attribute;
|
||||
public IReflectionField[] GetFields(BindingFlags bindingAttr);
|
||||
}
|
||||
|
||||
public interface IReflectionProvider
|
||||
{
|
||||
public IReflectionType[] GetTypes();
|
||||
public Dictionary<string, object> GetEnum(string enumName);
|
||||
}
|
||||
4
AquaMai/AquaMai.Config.Interfaces/Polyfills.cs
Normal file
4
AquaMai/AquaMai.Config.Interfaces/Polyfills.cs
Normal file
@@ -0,0 +1,4 @@
|
||||
namespace System.Runtime.CompilerServices
|
||||
{
|
||||
internal static class IsExternalInit {}
|
||||
}
|
||||
Reference in New Issue
Block a user