Exemplo n.º 1
0
            private void ReadElements()
            {
                Contract.Requires(
                    this.Reader.Name == "graph" &&
                    this.Reader.NamespaceURI == this.graphMLNamespace,
                    "incorrect reader position");

                ReadDelegateCompiler.SetGraphDefault(this.VisitedGraph);

                var vertices = new Dictionary <string, TVertex>(StringComparer.Ordinal);

                edge_id = 0;

                // read vertices or edges
                var reader = this.Reader;

                while (reader.Read())
                {
                    if (reader.NodeType == XmlNodeType.Element &&
                        reader.NamespaceURI == this.graphMLNamespace)
                    {
                        switch (reader.Name)
                        {
                        case "node":
                            this.ReadVertex(vertices);
                            break;

                        case "edge":
                            this.ReadEdge(vertices);
                            break;

                        //case "data":
                        //    GraphMLDeserializer<TVertex, TEdge, TGraph>.ReadDelegateCompiler.GraphAttributesReader(this.Reader, this.graphMLNamespace, this.VisitedGraph);
                        //    break;
                        default:
                            //throw new InvalidOperationException(String.Format("invalid reader position {0}:{1}", this.Reader.NamespaceURI, this.Reader.Name));
                            break;
                        }
                    }
                }
            }
            private void ReadElements()
            {
                Debug.Assert(
                    _reader.Name == GraphTag && _reader.NamespaceURI == _graphMLNamespace,
                    "Incorrect reader position.");

                ReadDelegateCompiler.SetGraphDefault(_graph);

                var vertices = new Dictionary <string, TVertex>(StringComparer.Ordinal);

                // Read vertices or edges
                XmlReader reader = _reader;

                while (reader.Read())
                {
                    if (reader.NodeType == XmlNodeType.Element &&
                        reader.NamespaceURI == _graphMLNamespace)
                    {
                        switch (reader.Name)
                        {
                        case NodeTag:
                            ReadVertex(vertices);
                            break;

                        case EdgeTag:
                            ReadEdge(vertices);
                            break;

                        case DataTag:
                            ReadDelegateCompiler.GraphAttributesReader(_reader, _graphMLNamespace, _graph);
                            break;

                        default:
                            throw new InvalidOperationException($"Invalid reader position {_reader.NamespaceURI}: {_reader.Name}.");
                        }
                    }
                }
            }