using System.Collections.Generic;
using AI.Interface;
using AI.Models.Form;
namespace AI.Service
{
///
/// 默认表单注册表,内置「加载散点文件」等表单定义。
///
public class FormRegistry : IFormRegistry
{
private readonly Dictionary _forms = new(StringComparer.OrdinalIgnoreCase);
public FormRegistry()
{
RegisterLoadXyzForm();
}
private void RegisterLoadXyzForm()
{
_forms["gridding-load-xyz"] = new FormDefinition
{
Id = "gridding-load-xyz",
Title = "加载散点文件",
SubmitTarget = "GriddingModuleLoadXyz",
SubmitLabel = "加载",
Fields = new List
{
new FormField
{
Id = "path",
Label = "文件路径",
Type = FormFieldType.FilePath,
Required = true,
},
},
};
}
///
public FormDefinition? GetForm(string formId)
{
return _forms.TryGetValue(formId ?? string.Empty, out var def) ? def : null;
}
///
public IEnumerable GetAll()
{
return _forms.Values;
}
}
}