mirror of
https://github.com/GeWuYou/GFramework.git
synced 2026-05-07 00:39:00 +08:00
- 实现YAML配置文件加载和JSON Schema校验功能 - 提供Source Generator自动生成配置类型和表包装类 - 添加VS Code插件支持配置浏览和表单编辑 - 支持跨表引用校验和开发期热重载功能 - 生成强类型的配置访问辅助方法和注册绑定 - 实现嵌套对象和对象数组的类型安全访问
90 lines
3.6 KiB
Plaintext
90 lines
3.6 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 strong-typed registry access so consumer projects do not need to duplicate the same conventions.
|
|
/// </summary>
|
|
public static class MonsterConfigBindings
|
|
{
|
|
/// <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>
|
|
/// 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>(
|
|
TableName,
|
|
ConfigRelativePath,
|
|
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 strong-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>(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 strong-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>(TableName, out var innerTable) && innerTable is not null)
|
|
{
|
|
table = new MonsterTable(innerTable);
|
|
return true;
|
|
}
|
|
|
|
table = null;
|
|
return false;
|
|
}
|
|
}
|