mirror of
https://github.com/GeWuYou/GFramework.git
synced 2026-05-08 09:34:30 +08:00
- 引入YAML配置源文件支持 - 实现JSON Schema结构描述功能 - 提供一对象一文件的目录组织方式 - 添加运行时只读查询能力 - 实现Source Generator生成配置类型和表包装 - 集成VS Code插件提供配置浏览和编辑功能 - 添加开发期热重载支持 - 提供跨表引用校验机制 - 创建配置生成器约定和绑定辅助类 - 添加详细的中文文档说明 - 实现集成测试验证生成器功能
121 lines
5.0 KiB
Plaintext
121 lines
5.0 KiB
Plaintext
// <auto-generated />
|
|
#nullable enable
|
|
|
|
namespace GFramework.Game.Config.Generated;
|
|
|
|
/// <summary>
|
|
/// Auto-generated registration and lookup helpers for schema file 'monster.schema.json'.
|
|
/// The helper centralizes table naming, config directory, schema path, and strongly-typed registry access so consumer projects do not need to duplicate the same conventions.
|
|
/// </summary>
|
|
public static class MonsterConfigBindings
|
|
{
|
|
/// <summary>
|
|
/// Groups the schema-derived metadata constants so consumer code can reuse one stable entry point.
|
|
/// </summary>
|
|
public static class Metadata
|
|
{
|
|
/// <summary>
|
|
/// Gets the logical config domain derived from the schema base name. The current runtime convention keeps this value aligned with the generated table name.
|
|
/// </summary>
|
|
public const string ConfigDomain = "monster";
|
|
|
|
/// <summary>
|
|
/// Gets the runtime registration name of the generated config table.
|
|
/// </summary>
|
|
public const string TableName = "monster";
|
|
|
|
/// <summary>
|
|
/// Gets the config directory path expected by the generated registration helper.
|
|
/// </summary>
|
|
public const string ConfigRelativePath = "monster";
|
|
|
|
/// <summary>
|
|
/// Gets the schema file path expected by the generated registration helper.
|
|
/// </summary>
|
|
public const string SchemaRelativePath = "schemas/monster.schema.json";
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets the logical config domain derived from the schema base name. The current runtime convention keeps this value aligned with the generated table name.
|
|
/// </summary>
|
|
public const string ConfigDomain = Metadata.ConfigDomain;
|
|
|
|
/// <summary>
|
|
/// Gets the runtime registration name of the generated config table.
|
|
/// </summary>
|
|
public const string TableName = Metadata.TableName;
|
|
|
|
/// <summary>
|
|
/// Gets the config directory path expected by the generated registration helper.
|
|
/// </summary>
|
|
public const string ConfigRelativePath = Metadata.ConfigRelativePath;
|
|
|
|
/// <summary>
|
|
/// Gets the schema file path expected by the generated registration helper.
|
|
/// </summary>
|
|
public const string SchemaRelativePath = Metadata.SchemaRelativePath;
|
|
|
|
/// <summary>
|
|
/// Registers the generated config table using the schema-derived runtime conventions.
|
|
/// </summary>
|
|
/// <param name="loader">The target YAML config loader.</param>
|
|
/// <param name="comparer">Optional key comparer for the generated table registration.</param>
|
|
/// <returns>The same loader instance so registration can keep chaining.</returns>
|
|
public static global::GFramework.Game.Config.YamlConfigLoader RegisterMonsterTable(
|
|
this global::GFramework.Game.Config.YamlConfigLoader loader,
|
|
global::System.Collections.Generic.IEqualityComparer<int>? comparer = null)
|
|
{
|
|
if (loader is null)
|
|
{
|
|
throw new global::System.ArgumentNullException(nameof(loader));
|
|
}
|
|
|
|
return loader.RegisterTable<int, MonsterConfig>(
|
|
Metadata.TableName,
|
|
Metadata.ConfigRelativePath,
|
|
Metadata.SchemaRelativePath,
|
|
static config => config.Id,
|
|
comparer);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets the generated config table wrapper from the registry.
|
|
/// </summary>
|
|
/// <param name="registry">The source config registry.</param>
|
|
/// <returns>The generated strongly-typed table wrapper.</returns>
|
|
/// <exception cref="global::System.ArgumentNullException">When <paramref name="registry"/> is null.</exception>
|
|
public static MonsterTable GetMonsterTable(this global::GFramework.Game.Abstractions.Config.IConfigRegistry registry)
|
|
{
|
|
if (registry is null)
|
|
{
|
|
throw new global::System.ArgumentNullException(nameof(registry));
|
|
}
|
|
|
|
return new MonsterTable(registry.GetTable<int, MonsterConfig>(Metadata.TableName));
|
|
}
|
|
|
|
/// <summary>
|
|
/// Tries to get the generated config table wrapper from the registry.
|
|
/// </summary>
|
|
/// <param name="registry">The source config registry.</param>
|
|
/// <param name="table">The generated strongly-typed table wrapper when lookup succeeds; otherwise null.</param>
|
|
/// <returns>True when the generated table is registered and type-compatible; otherwise false.</returns>
|
|
/// <exception cref="global::System.ArgumentNullException">When <paramref name="registry"/> is null.</exception>
|
|
public static bool TryGetMonsterTable(this global::GFramework.Game.Abstractions.Config.IConfigRegistry registry, out MonsterTable? table)
|
|
{
|
|
if (registry is null)
|
|
{
|
|
throw new global::System.ArgumentNullException(nameof(registry));
|
|
}
|
|
|
|
if (registry.TryGetTable<int, MonsterConfig>(Metadata.TableName, out var innerTable) && innerTable is not null)
|
|
{
|
|
table = new MonsterTable(innerTable);
|
|
return true;
|
|
}
|
|
|
|
table = null;
|
|
return false;
|
|
}
|
|
}
|