private void BuildContextTree(BindableObject root, ContextNode context, Dictionary <Hugula.Databinding.BindableObject, ContextNode> sourceContext) { // Debug.LogFormat("BuildContextTree({0}) ", root); binderCount += root.GetBindings().Count; ContextNode currContext = context; var contextBinding = root.GetBindingByName("context"); if (contextBinding != null) { var ctype = ContextType.NotifyObject; if (root is BindableContainer) { ctype = ContextType.NotifyObject; } else if (root is ICollectionBinder) { ctype = ContextType.NotifyTable; } currContext = context.FindContext(contextBinding, ctype);//寻找上下文 } else { // Debug.LogFormat("{0}.context = nil ", root); } sourceContext[root] = currContext; object target = root; var binders = root.GetBindings(); foreach (var binder in binders) { if (binder != contextBinding && binder.path.Trim() != ".") { AddPropertyToContext(target, binder, true, currContext, sourceContext); } } //children if (root is ICollectionBinder) { var container = root as Hugula.Databinding.ICollectionBinder; var children = container.GetChildren(); foreach (var item in children) { // NodeGUI node = null; if (item is ICollectionBinder) //如果是容器 { BuildContextTree(item, currContext, sourceContext); } else if (item != null) { binderCount += item.GetBindings().Count; binders = item.GetBindings(); target = item; foreach (var binder in binders) { if (binder.propertyName != "context" && binder.path != ".") { AddPropertyToContext(target, binder, false, currContext, sourceContext); } } } } } }
public static void RemoveAtbindableObjects(BindableObject target, int index) { var binding = target.GetBindings(); binding.RemoveAt(index); }