private static void LoadXml(XElement elt, VisualElementAsset parent, VisualTreeAsset vta, StyleSheetBuilder ssb) { VisualElementAsset vea; if (!ResolveType(elt, vta, out vea)) { logger.LogError(ImportErrorType.Semantic, ImportErrorCode.UnknownElement, elt.Name.LocalName, Error.Level.Fatal, elt); return; } var parentId = (parent == null ? 0 : parent.id); // id includes the parent id, meaning it's dependent on the whole direct hierarchy int id = (parentId << 1) ^ vea.GetHashCode(); vea.parentId = parentId; vea.id = id; bool startedRule = ParseAttributes(elt, vea, ssb, vta, parent); // each vea will creates 0 or 1 style rule, with one or more properties // they don't have selectors and are directly referenced by index // it's then applied during tree cloning vea.ruleIndex = startedRule ? ssb.EndRule() : -1; if (vea is TemplateAsset) { vta.templateAssets.Add((TemplateAsset)vea); } else { vta.visualElementAssets.Add(vea); } if (elt.HasElements) { foreach (XElement child in elt.Elements()) { if (child.Name.LocalName == k_StyleReferenceNode) { LoadStyleReferenceNode(vea, child); } else { LoadXml(child, vea, vta, ssb); } } } }
private static void LoadXml(XElement elt, VisualElementAsset parent, VisualTreeAsset vta, StyleSheetBuilder ssb) { VisualElementAsset visualElementAsset; if (!UIElementsViewImporter.ResolveType(elt, vta, out visualElementAsset)) { UIElementsViewImporter.logger.LogError(ImportErrorType.Semantic, ImportErrorCode.UnknownElement, elt.Name.LocalName, UIElementsViewImporter.Error.Level.Fatal, elt); } else { int num = (parent != null) ? parent.id : 0; int id = num << 1 ^ visualElementAsset.GetHashCode(); visualElementAsset.parentId = num; visualElementAsset.id = id; bool flag = UIElementsViewImporter.ParseAttributes(elt, visualElementAsset, ssb, vta, parent); visualElementAsset.ruleIndex = ((!flag) ? -1 : ssb.EndRule()); if (visualElementAsset is TemplateAsset) { vta.templateAssets.Add((TemplateAsset)visualElementAsset); } else { vta.visualElementAssets.Add(visualElementAsset); } if (elt.HasElements) { foreach (XElement current in elt.Elements()) { if (current.Name.LocalName == "Style") { UIElementsViewImporter.LoadStyleReferenceNode(visualElementAsset, current); } else { UIElementsViewImporter.LoadXml(current, visualElementAsset, vta, ssb); } } } } }