public void ResetBridgeRootElement() { // reset root root = Flex.CreateDefaultNode(); var ra = CreateRuntimeNodeAttribute(root, templateRoot); // copy style var ctxs = GenerateContextStack(); ProcessStyleBind(root, ctxs); // el-bind var elBindDict = new Dictionary <string, object>(); if (templateRoot.attributeDataBindExpressList != null) { foreach (var attr in templateRoot.attributeDataBindExpressList) { if (attr.TryEvaluate(ctxs, out var obj)) { elBindDict[attr.TargetName] = obj; } } } var eleRoot = bridge.CreateElement(root, templateRoot.TagName, elBindDict); ra.element = eleRoot; bridge.OnSetRoot(eleRoot); }
Node RenderTemplateTree(TemplateNode tnode, ContextStack contextStack, object forContext) { Node node = Flex.CreateDefaultNode(); var ra = CreateRuntimeNodeAttribute(node, tnode); // set el-for value ra.forExpressItemCurrentValue = forContext; // copy style Style.Copy(node.nodeStyle, tnode.nodeStyle); // process node el-bind var originalAttrs = ra.attributes; foreach (var attr in tnode.attributeDataBindExpressList) { if (attr.TryEvaluate(contextStack, out var attrValue)) { if (originalAttrs.TryGetValue(attr, out var oldValue) && oldValue == attrValue) { // equal and not // Console.WriteLine("no need to process style"); } else { ra.attributes[attr] = attrValue; ProcessNodeStyle(node, attr.TargetName, attrValue != null ? attrValue.ToString() : ""); } } else { ra.attributes.Remove(attr); } } // process innerText if (tnode.textDataBindExpress != null) { ra.textDataBindExpressCurrentValue = tnode.textDataBindExpress.Evaluate(contextStack); } // render children ra.ResetChildren((appendChild) => { foreach (var vchild in tnode.Children) { foreach (var child in RenderTemplateTreeExpand(vchild, contextStack)) { node.AddChild(child); appendChild(vchild, child); } } }); return(node); }