private static TreeNode BuildDataElementsTreeNode(XElement element, Tree tree) { XAttribute typeAttribute = element.Attribute("Type"); XAttribute labelAttribute = element.Attribute("Label"); XAttribute toolTipAttribute = element.Attribute("ToolTip"); XAttribute iconAttribute = element.Attribute("Icon"); XAttribute openedIconAttribute = element.Attribute("OpenedIcon"); XAttribute showForeignItemsAttribute = element.Attribute("ShowForeignItems"); XAttribute leafDisplayAttribute = element.Attribute("Display"); if (typeAttribute == null) { tree.AddValidationError(element, "TreeValidationError.Common.MissingAttribute", "Type"); return null; } Type interfaceType = TypeManager.TryGetType(typeAttribute.Value); if (interfaceType == null) { tree.AddValidationError(element, "TreeValidationError.Common.UnknownInterfaceType", typeAttribute.Value); return null; } LeafDisplayMode leafDisplay = LeafDisplayModeHelper.ParseDisplayMode(leafDisplayAttribute, tree); ResourceHandle icon = null; if (iconAttribute != null) icon = FactoryHelper.GetIcon(iconAttribute.Value); ResourceHandle openedIcon = null; if (icon != null && openedIconAttribute == null) openedIcon = icon; else if (openedIconAttribute != null) openedIcon = FactoryHelper.GetIcon(openedIconAttribute.Value); var dataElementsTreeNode = new DataElementsTreeNode { Tree = tree, Id = tree.BuildProcessContext.CreateNewNodeId(), InterfaceType = interfaceType, Label = labelAttribute.GetValueOrDefault(null), ToolTip = toolTipAttribute.GetValueOrDefault(null), Icon = icon, OpenedIcon = openedIcon, ShowForeignItems = showForeignItemsAttribute.GetValueOrDefault("true").ToLowerInvariant() == "true", Display = leafDisplay }; List<TreeNode> treeNodes; if (tree.BuildProcessContext.DataInteraceToTreeNodes.TryGetValue(interfaceType, out treeNodes) == false) { treeNodes = new List<TreeNode>(); tree.BuildProcessContext.DataInteraceToTreeNodes.Add(interfaceType, treeNodes); } treeNodes.Add(dataElementsTreeNode); return dataElementsTreeNode; }
private static TreeNode BuildDataElementsTreeNode(XElement element, Tree tree) { XAttribute typeAttribute = element.Attribute("Type"); XAttribute labelAttribute = element.Attribute("Label"); XAttribute toolTipAttribute = element.Attribute("ToolTip"); XAttribute iconAttribute = element.Attribute("Icon"); XAttribute openedIconAttribute = element.Attribute("OpenedIcon"); XAttribute showForeignItemsAttribute = element.Attribute("ShowForeignItems"); XAttribute leafDisplayAttribute = element.Attribute("Display"); if (typeAttribute == null) { tree.AddValidationError(element, "TreeValidationError.Common.MissingAttribute", "Type"); return(null); } Type interfaceType = TypeManager.TryGetType(typeAttribute.Value); if (interfaceType == null) { tree.AddValidationError(element, "TreeValidationError.Common.UnknownInterfaceType", typeAttribute.Value); return(null); } LeafDisplayMode leafDisplay = LeafDisplayModeHelper.ParseDisplayMode(leafDisplayAttribute, tree); ResourceHandle icon = null; if (iconAttribute != null) { icon = FactoryHelper.GetIcon(iconAttribute.Value); } ResourceHandle openedIcon = null; if (icon != null && openedIconAttribute == null) { openedIcon = icon; } else if (openedIconAttribute != null) { openedIcon = FactoryHelper.GetIcon(openedIconAttribute.Value); } var dataElementsTreeNode = new DataElementsTreeNode { Tree = tree, Id = tree.BuildProcessContext.CreateNewNodeId(), InterfaceType = interfaceType, Label = labelAttribute.GetValueOrDefault(null), ToolTip = toolTipAttribute.GetValueOrDefault(null), Icon = icon, OpenedIcon = openedIcon, ShowForeignItems = showForeignItemsAttribute.GetValueOrDefault("true").ToLowerInvariant() == "true", Display = leafDisplay }; List <TreeNode> treeNodes; if (tree.BuildProcessContext.DataInteraceToTreeNodes.TryGetValue(interfaceType, out treeNodes) == false) { treeNodes = new List <TreeNode>(); tree.BuildProcessContext.DataInteraceToTreeNodes.Add(interfaceType, treeNodes); } treeNodes.Add(dataElementsTreeNode); return(dataElementsTreeNode); }