Esempio n. 1
0
        //////////////////////////////////////////////////////////////////////////
        /// <summary>
        /// Initialize an adpater for a XmlNode attached to TreeNode
        /// </summary>
        /// <param name="node">Xml node to adapt</param>
        //////////////////////////////////////////////////////////////////////////
        internal XmlDescriptor(XmlNode node)
        {
            m_Dictionary = new Dictionary<string, object>();
            ICollection<string> attributes = node.Attributes;

            // Extract all node's attributes
            foreach (string attribute in attributes)
                m_Dictionary.Add(attribute, node[attribute]);
        }
Esempio n. 2
0
 //////////////////////////////////////////////////////////////////////////
 /// <summary>
 /// Add a child node.
 /// </summary>
 /// <param name="child">The child to add.</param>
 //////////////////////////////////////////////////////////////////////////
 public void Add(XmlNode child)
 {
     m_Children.Add(child);
 }
Esempio n. 3
0
        //////////////////////////////////////////////////////////////////////////
        /// <summary>
        /// Build recursivly a node of a branch from an NAntNode.
        /// </summary>
        /// <param name="nantNode">The NAntNode to build.</param>
        /// <returns>The root of the branch.</returns>
        //////////////////////////////////////////////////////////////////////////
        public static TreeNode CreateTreeNode(XmlNode nantNode)
        {
            // Set the title of node with nantNode name
            string title = nantNode.Name;

            // For target/property we take the name of the target/property
            if (nantNode.Name == AppConstants.NANT_XML_TARGET
                || nantNode.Name == AppConstants.NANT_XML_PROPERTY)
                title = nantNode["name"];

            // Initialize the root node
            TreeNode root = new TreeNode(title);

            // Attache nantNode to tree view node
            root.Tag = nantNode;

            // Retrieve the children of node
            IList<XmlNode> children = nantNode.Children;

            if (children != null)
            {
                // Build each child recurvively
                foreach (XmlNode child in children)
                {
                    if (nantNode.Name != AppConstants.NANT_XML_TARGET)
                    {
                        // Build a node and add to parent
                        TreeNode node = CreateTreeNode(child);
                        root.Nodes.Add(node);
                    }
                }
            }

            return root;
        }