优化ui绑定侧逻辑

This commit is contained in:
2026-07-25 23:45:29 +08:00
parent 3fbb82f40e
commit 251b8730b9
19 changed files with 782 additions and 436 deletions
@@ -91,6 +91,12 @@ namespace XericUI.ReflectionUIGenerator
bindingCollection.SourceMetaDataSet = this;
var scheduler = new AvrgMvvmScheduler(resolverConfig);
// ★ 构建前缀树索引
var trie = new AvrgBindingTrie();
string typePrefix = businessTarget != null
? businessTarget.GetType().FullName + "."
: "";
foreach (var metaData in _metaDataList)
{
if (metaData.AccessorFactory == null) continue;
@@ -137,9 +143,14 @@ namespace XericUI.ReflectionUIGenerator
string subPath = subMetaData.PropertyPath;
if (string.IsNullOrEmpty(subPath)) continue;
// 创建子属性访问器
var subAccessor = new AvrgSubPropertyAccessor(
accessor, subPath, subMetaData);
var subBinding = new AvrgMvvmBinding
{
MetaData = subMetaData,
Accessor = subAccessor,
ReadFunc = () => ReadSubProperty(accessor.GetValue(), subPath),
WriteAction = (val) =>
{
@@ -157,8 +168,13 @@ namespace XericUI.ReflectionUIGenerator
// 注册到调度器
scheduler.Register(binding);
bindingCollection.Add(binding);
// ★ 插入前缀树(完整路径: Type.FullName.MemberName)
string fullPath = typePrefix + metaData.MemberName;
trie.Insert(fullPath, binding);
}
bindingCollection.SetTrie(trie);
bindingCollection.AttachScheduler(scheduler);
return bindingCollection;
}