Files
TEngine/Luban/Luban.ClientServer/Templates/config/cs_bin/tables.tpl
ALEXTANG aa0d40c758 修改luban模板配置,支持异步加载配置实例
修改luban模板配置,支持异步加载配置实例
2023-08-15 12:07:21 +08:00

46 lines
1.1 KiB
Smarty

using Bright.Serialization;
using System.Threading.Tasks;
{{
name = x.name
namespace = x.namespace
tables = x.tables
}}
namespace {{namespace}}
{
public sealed class {{name}}
{
{{~for table in tables ~}}
{{~if table.comment != '' ~}}
/// <summary>
/// {{table.escape_comment}}
/// </summary>
{{~end~}}
public {{table.full_name}} {{table.name}} {get; private set; }
{{~end~}}
public {{name}}() { }
public async Task LoadAsync(System.Func<string, Task<ByteBuf>> loader)
{
var tables = new System.Collections.Generic.Dictionary<string, object>();
{{~for table in tables ~}}
{{table.name}} = new {{table.full_name}}(await loader("{{table.output_data_file}}"));
tables.Add("{{table.full_name}}", {{table.name}});
{{~end~}}
{{~for table in tables ~}}
{{table.name}}.Resolve(tables);
{{~end~}}
}
public void TranslateText(System.Func<string, string, string> translator)
{
{{~for table in tables ~}}
{{table.name}}.TranslateText(translator);
{{~end~}}
}
}
}