示例#1
0
        ParseGraphMLAttributeDefinitions
        (
            XmlNode oGraphMLXmlNode,
            XmlNamespaceManager oXmlNamespaceManager
        )
        {
            Debug.Assert(oGraphMLXmlNode != null);
            Debug.Assert(oXmlNamespaceManager != null);
            AssertValid();

            Dictionary <String, GraphMLAttribute> oGraphMLAttributeDictionary =
                new Dictionary <String, GraphMLAttribute>();

            // Read the GraphML-attribute nodes.

            foreach (XmlNode oKeyXmlNode in oGraphMLXmlNode.SelectNodes(
                         GraphMLPrefix + ":key[@for='node' or @for='edge']",
                         oXmlNamespaceManager))
            {
                GraphMLAttribute oGraphMLAttribute =
                    new GraphMLAttribute(oKeyXmlNode, oXmlNamespaceManager,
                                         GraphMLPrefix);

                String sID = oGraphMLAttribute.ID;

                try
                {
                    oGraphMLAttributeDictionary.Add(sID, oGraphMLAttribute);
                }
                catch (ArgumentException)
                {
                    throw new XmlException(
                              "The key id \"" + sID + "\" exists for two keys.  Key id"
                              + " values must be unique."
                              );
                }
            }

            return(oGraphMLAttributeDictionary);
        }
        //*************************************************************************
        //  Method: ParseGraphMLAttributeDefinitions()
        //
        /// <summary>
        /// Parses the GraphML vertex and edge attribute definitions.
        /// </summary>
        ///
        /// <param name="oGraphMLXmlNode">
        /// "graphml" XML node.
        /// </param>
        ///
        /// <param name="oXmlNamespaceManager">
        /// XML namespace manager.
        /// </param>
        ///
        /// <returns>
        /// The key is the id attribute of a "key" XML node, and the value is the
        /// corresponding GraphMLAttribute object.
        /// </returns>
        ///
        /// <remarks>
        /// For each "key" XML node, a <see cref="GraphMLAttribute" /> object is
        /// created and added to the returned dictionary.
        /// </remarks>
        //*************************************************************************
        protected Dictionary<String, GraphMLAttribute> ParseGraphMLAttributeDefinitions(
            XmlNode oGraphMLXmlNode,
            XmlNamespaceManager oXmlNamespaceManager
            )
        {
            Debug.Assert(oGraphMLXmlNode != null);
            Debug.Assert(oXmlNamespaceManager != null);
            AssertValid();

            Dictionary<String, GraphMLAttribute> oGraphMLAttributeDictionary =
            new Dictionary<String, GraphMLAttribute>();

            // Read the GraphML-attribute nodes.

            foreach ( XmlNode oKeyXmlNode in oGraphMLXmlNode.SelectNodes(
            GraphMLPrefix + ":key[@for='node' or @for='edge']",
            oXmlNamespaceManager) )
            {
            GraphMLAttribute oGraphMLAttribute =
                new GraphMLAttribute(oKeyXmlNode, oXmlNamespaceManager,
                    GraphMLPrefix);

            String sID = oGraphMLAttribute.ID;

            try
            {
                oGraphMLAttributeDictionary.Add(sID, oGraphMLAttribute);
            }
            catch (ArgumentException)
            {
                throw new XmlException(
                    "The key id \"" + sID + "\" exists for two keys.  Key id"
                    + " values must be unique."
                    );
            }
            }

            return (oGraphMLAttributeDictionary);
        }