mirror of
https://github.com/GeWuYou/GFramework.git
synced 2026-05-07 00:39:00 +08:00
docs(config): 更新 GodotYamlConfigLoader 异步加载方法的文档注释
- 添加了详细的 XML 文档注释说明方法功能和参数 - 补充了异常情况的详细说明包括 ArgumentNullException 和 ConfigLoadException - 添加了关于运行时缓存同步执行原因的技术备注 - 保留了原有的继承特性标记并添加了完整的文档结构
This commit is contained in:
parent
1bf5d287e9
commit
86ff04680b
@ -3,7 +3,6 @@ using GFramework.Core.Abstractions.Events;
|
||||
using GFramework.Game.Abstractions.Config;
|
||||
using GFramework.Game.Config;
|
||||
using GFramework.Godot.Extensions;
|
||||
using FileAccess = Godot.FileAccess;
|
||||
|
||||
namespace GFramework.Godot.Config;
|
||||
|
||||
@ -110,13 +109,33 @@ public sealed class GodotYamlConfigLoader : IConfigLoader
|
||||
/// </summary>
|
||||
public bool CanEnableHotReload => UsesSourceDirectoryDirectly(SourceRootPath);
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
/// 执行 Godot 场景下的配置加载。
|
||||
/// 当源目录无法直接作为普通文件系统目录访问时,加载器会先把显式声明的 YAML 与 schema 文本同步到运行时缓存,
|
||||
/// 再委托底层 <see cref="YamlConfigLoader" /> 完成解析与注册。
|
||||
/// </summary>
|
||||
/// <param name="registry">用于接收配置表的注册表。</param>
|
||||
/// <param name="cancellationToken">取消令牌。</param>
|
||||
/// <returns>表示加载流程的异步任务。</returns>
|
||||
/// <exception cref="ArgumentNullException">当 <paramref name="registry" /> 为 <see langword="null" /> 时抛出。</exception>
|
||||
/// <exception cref="ConfigLoadException">
|
||||
/// 当缓存同步、配置文件读取、schema 读取或底层 YAML 加载失败时抛出。
|
||||
/// </exception>
|
||||
/// <remarks>
|
||||
/// 运行时缓存同步阶段刻意保持同步执行。
|
||||
/// 原因在于默认宿主环境可能需要通过 Godot 的目录和文件访问 API 读取 <c>res://</c> 资源,
|
||||
/// 而这些访问边界目前仅以同步委托形式暴露;同时底层 <see cref="YamlConfigLoader" /> 也要求缓存文件在开始读取前已经完整落盘。
|
||||
/// 这意味着当实例无法直接访问源目录时,调用线程会在进入真正的异步 YAML 解析前承担一次文件系统同步成本。
|
||||
/// </remarks>
|
||||
public async Task LoadAsync(IConfigRegistry registry, CancellationToken cancellationToken = default)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(registry);
|
||||
|
||||
if (!CanEnableHotReload)
|
||||
{
|
||||
// Runtime cache preparation must finish before the underlying loader starts enumerating files.
|
||||
// This step intentionally stays synchronous because the default Godot environment exposes
|
||||
// directory enumeration and file reads through synchronous engine/file-system APIs only.
|
||||
SynchronizeRuntimeCache(cancellationToken);
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user