Esempio n. 1
0
        public static void DeserializeFromGraphML <TVertex, TEdge, TGraph>(
#if !NET20
            this
#endif
            TGraph graph,
            TextReader reader,
            IdentifiableVertexFactory <TVertex> vertexFactory,
            IdentifiableEdgeFactory <TVertex, TEdge> edgeFactory
            )
            where TEdge : IEdge <TVertex>
            where TGraph : IMutableVertexAndEdgeListGraph <TVertex, TEdge>
        {
            Contract.Requires(graph != null);
            Contract.Requires(reader != null);
            Contract.Requires(vertexFactory != null);
            Contract.Requires(edgeFactory != null);

            var settings = new XmlReaderSettings();

#if !SILVERLIGHT
            //settings.DtdProcessing = DtdProcessing.Prohibit;// settings.ProhibitDtd = false;
            settings.ValidationFlags = XmlSchemaValidationFlags.None;
#endif
            settings.XmlResolver = new GraphMLXmlResolver();

            using (var xreader = XmlReader.Create(reader, settings))
                DeserializeFromGraphML <TVertex, TEdge, TGraph>(graph, xreader, vertexFactory, edgeFactory);
        }
        /// <summary>
        /// Deserializes a graph instance from the given <paramref name="reader"/> into the given <paramref name="graph"/>.
        /// </summary>
        /// <param name="reader">The XML reader.</param>
        /// <param name="graph">Graph instance to fill.</param>
        /// <param name="vertexFactory">Vertex factory method.</param>
        /// <param name="edgeFactory">Edge factory method.</param>
        /// <exception cref="T:System.ArgumentNullException"><paramref name="reader"/> is <see langword="null"/>.</exception>
        /// <exception cref="T:System.ArgumentNullException"><paramref name="graph"/> is <see langword="null"/>.</exception>
        /// <exception cref="T:System.ArgumentNullException"><paramref name="vertexFactory"/> is <see langword="null"/>.</exception>
        /// <exception cref="T:System.ArgumentNullException"><paramref name="edgeFactory"/> is <see langword="null"/>.</exception>
        /// <exception cref="T:System.InvalidOperationException">Deserializing value on property without setter, or with invalid default value.</exception>
        /// <exception cref="T:System.InvalidOperationException"><see cref="GraphMLTag"/> or <see cref="GraphTag"/> not found.</exception>
        /// <exception cref="T:System.InvalidOperationException">Failure while reading elements from GraphML.</exception>
        /// <exception cref="T:System.NotSupportedException">Deserializing graph with unsupported property type.</exception>
        public void Deserialize(
            [NotNull] XmlReader reader,
            [NotNull] TGraph graph,
            [NotNull] IdentifiableVertexFactory <TVertex> vertexFactory,
            [NotNull] IdentifiableEdgeFactory <TVertex, TEdge> edgeFactory)
        {
            if (reader is null)
            {
                throw new ArgumentNullException(nameof(reader));
            }
            if (graph == null)
            {
                throw new ArgumentNullException(nameof(graph));
            }
            if (vertexFactory is null)
            {
                throw new ArgumentNullException(nameof(vertexFactory));
            }
            if (edgeFactory is null)
            {
                throw new ArgumentNullException(nameof(edgeFactory));
            }

            var worker = new ReaderWorker(reader, graph, vertexFactory, edgeFactory);

            worker.Deserialize();
        }
        public static void DeserializeAndValidateFromGraphML <TVertex, TEdge, TGraph>(
            this TGraph graph, TextReader reader,
            IdentifiableVertexFactory <TVertex> vertexFactory,
            IdentifiableEdgeFactory <TVertex, TEdge> edgeFactory
            )
            where TEdge : IEdge <TVertex>
            where TGraph : IMutableVertexAndEdgeListGraph <TVertex, TEdge>
        {
            Contract.Requires(graph != null);
            Contract.Requires(reader != null);
            Contract.Requires(vertexFactory != null);
            Contract.Requires(edgeFactory != null);

            var serializer = new GraphMLDeserializer <TVertex, TEdge, TGraph>();
            var settings   = new XmlReaderSettings();

            // add graphxml schema
            settings.ValidationType = ValidationType.Schema;
            settings.XmlResolver    = new GraphMLXmlResolver();
            AddGraphMLSchema <TVertex, TEdge, TGraph>(settings);

            try
            {
                settings.ValidationEventHandler += new System.Xml.Schema.ValidationEventHandler(ValidationEventHandler);

                // reader and validating
                using (var xreader = XmlReader.Create(reader, settings))
                    serializer.Deserialize(xreader, graph, vertexFactory, edgeFactory);
            }
            finally
            {
                settings.ValidationEventHandler -= new System.Xml.Schema.ValidationEventHandler(ValidationEventHandler);
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Deserializes from the given <paramref name="reader"/> (GraphML graph) into the given <paramref name="graph"/>.
        /// </summary>
        /// <typeparam name="TVertex">Vertex type.</typeparam>
        /// <typeparam name="TEdge">Edge type.</typeparam>
        /// <typeparam name="TGraph">Graph type.</typeparam>
        /// <param name="graph">Graph instance to fill.</param>
        /// <param name="reader">Reader stream.</param>
        /// <param name="vertexFactory">Vertex factory method.</param>
        /// <param name="edgeFactory">Edge factory method.</param>
        /// <exception cref="T:System.ArgumentNullException"><paramref name="graph"/> is <see langword="null"/>.</exception>
        /// <exception cref="T:System.ArgumentNullException"><paramref name="reader"/> is <see langword="null"/>.</exception>
        /// <exception cref="T:System.ArgumentNullException"><paramref name="vertexFactory"/> is <see langword="null"/>.</exception>
        /// <exception cref="T:System.ArgumentNullException"><paramref name="edgeFactory"/> is <see langword="null"/>.</exception>
        /// <exception cref="T:System.InvalidOperationException">Deserializing value on property without setter, or with invalid default value.</exception>
        /// <exception cref="T:System.InvalidOperationException"><see cref="XmlConstants.GraphMLTag"/> or <see cref="XmlConstants.GraphTag"/> not found.</exception>
        /// <exception cref="T:System.InvalidOperationException">Failure while reading elements from GraphML.</exception>
        /// <exception cref="T:System.NotSupportedException">Deserializing graph with unsupported property type.</exception>
        public static void DeserializeFromGraphML <TVertex, TEdge, TGraph>(
            [NotNull] this TGraph graph,
            [NotNull] TextReader reader,
            [NotNull] IdentifiableVertexFactory <TVertex> vertexFactory,
            [NotNull] IdentifiableEdgeFactory <TVertex, TEdge> edgeFactory)
            where TEdge : IEdge <TVertex>
            where TGraph : IMutableVertexAndEdgeSet <TVertex, TEdge>
        {
            if (reader is null)
            {
                throw new ArgumentNullException(nameof(reader));
            }

#if SUPPORTS_XML_DTD_PROCESSING
            var settings = new XmlReaderSettings
            {
                ValidationFlags = XmlSchemaValidationFlags.None,
                XmlResolver     = new GraphMLXmlResolver(),
                DtdProcessing   = DtdProcessing.Ignore
            };

            using (XmlReader xmlReader = XmlReader.Create(reader, settings))
                DeserializeFromGraphML(graph, xmlReader, vertexFactory, edgeFactory);
#else
            var xmlReader = new XmlTextReader(reader)
            {
                XmlResolver = null
            };

            DeserializeFromGraphML(graph, xmlReader, vertexFactory, edgeFactory);
#endif
        }
        public DependencyGraph(IState persistentState)
        {
            var state = persistentState as DependencyGraphState;

            if (state == null)
            {
                throw new WorkflowEngineException(
                          "DependencyGraph must be loaded with an object of type DependencyGraphState");
            }

            _executedPlugins = state.ExecutedPlugins;
            _consumes        = state.Consumes.ToDictionary(kv => new PluginId(kv.Key), kv => kv.Value);
            _createdBy       = state.CreatedBy.ToDictionary(kv => new PluginDataId(kv.Key), kv => kv.Value);
            _graph           = new BidirectionalGraph <PluginId, SEdge <PluginId> >();
            using (var stream = new MemoryStream())
            {
                using (var streamWriter = new StreamWriter(stream))
                {
                    streamWriter.Write(state.Graph);
                    streamWriter.Flush();
                    stream.Position = 0;
                    using (var xmlReader = XmlReader.Create(stream))
                    {
                        var vertexFactory = new IdentifiableVertexFactory <PluginId>(pluginId => new PluginId(pluginId));
                        var edgeFactory   = new IdentifiableEdgeFactory <PluginId, SEdge <PluginId> >((source, target, id) => new SEdge <PluginId>(source, target));
                        _graph.DeserializeFromGraphML(xmlReader, vertexFactory, edgeFactory);
                    }
                }
            }
        }
Esempio n. 6
0
        /// <summary>
        /// Deserializes from XML <paramref name="reader"/> (GraphML graph) into the given <paramref name="graph"/>.
        /// </summary>
        /// <typeparam name="TVertex">Vertex type.</typeparam>
        /// <typeparam name="TEdge">Edge type.</typeparam>
        /// <typeparam name="TGraph">Graph type.</typeparam>
        /// <param name="graph">Graph instance to fill.</param>
        /// <param name="reader">The XML reader.</param>
        /// <param name="vertexFactory">Vertex factory method.</param>
        /// <param name="edgeFactory">Edge factory method.</param>
        /// <exception cref="T:System.ArgumentNullException"><paramref name="graph"/> is <see langword="null"/>.</exception>
        /// <exception cref="T:System.ArgumentNullException"><paramref name="reader"/> is <see langword="null"/>.</exception>
        /// <exception cref="T:System.ArgumentNullException"><paramref name="vertexFactory"/> is <see langword="null"/>.</exception>
        /// <exception cref="T:System.ArgumentNullException"><paramref name="edgeFactory"/> is <see langword="null"/>.</exception>
        /// <exception cref="T:System.InvalidOperationException">Deserializing value on property without setter, or with invalid default value.</exception>
        /// <exception cref="T:System.InvalidOperationException"><see cref="XmlConstants.GraphMLTag"/> or <see cref="XmlConstants.GraphTag"/> not found.</exception>
        /// <exception cref="T:System.InvalidOperationException">Failure while reading elements from GraphML.</exception>
        /// <exception cref="T:System.NotSupportedException">Deserializing graph with unsupported property type.</exception>
        public static void DeserializeFromGraphML <TVertex, TEdge, TGraph>(
            [NotNull] this TGraph graph,
            [NotNull] XmlReader reader,
            [NotNull] IdentifiableVertexFactory <TVertex> vertexFactory,
            [NotNull] IdentifiableEdgeFactory <TVertex, TEdge> edgeFactory)
            where TEdge : IEdge <TVertex>
            where TGraph : IMutableVertexAndEdgeSet <TVertex, TEdge>
        {
            var serializer = new GraphMLDeserializer <TVertex, TEdge, TGraph>();

            serializer.Deserialize(reader, graph, vertexFactory, edgeFactory);
        }
Esempio n. 7
0
        public void deserialize()
        {
            AdjacencyGraph <Fief, TaggedEdge <Fief, string> > tmpGraph = new AdjacencyGraph <Fief, TaggedEdge <Fief, string> >();
            IdentifiableVertexFactory <Fief> fiefFactory = new IdentifiableVertexFactory <Fief>(getFiefFromID);
            IdentifiableEdgeFactory <Fief, TaggedEdge <Fief, string> > edgeFactory = new IdentifiableEdgeFactory <Fief, TaggedEdge <Fief, string> >(CreateEdge);

            using (var xwriter = XmlReader.Create("graphTest.bin"))
            {
                tmpGraph.DeserializeFromGraphML <Fief, TaggedEdge <Fief, string>, AdjacencyGraph <Fief, TaggedEdge <Fief, string> > >(xwriter, fiefFactory, edgeFactory);
            }
            this.myMap = tmpGraph;
        }
Esempio n. 8
0
        public static SEGraph Deserialize(string path)
        {
            var deser = new GraphMLDeserializer <SENode, SEEdge, SEGraph>();
            var graph = new SEGraph();
            var ivf   = new IdentifiableVertexFactory <SENode>(SENode.Factory);
            var ief   = new IdentifiableEdgeFactory <SENode, SEEdge>(SEEdge.Factory);

            using (var reader = XmlReader.Create(path))
            {
                deser.Deserialize(reader, graph, ivf, ief);
            }
            ReplaceLineBreaks(graph, false);
            return(graph);
        }
Esempio n. 9
0
        public static SoftMutableBidirectionalGraph <CFGNode, CFGEdge> Deserialize(string path)
        {
            var deser = new GraphMLDeserializer <CFGNode, CFGEdge, SoftMutableBidirectionalGraph <CFGNode, CFGEdge> >();
            var graph = new SoftMutableBidirectionalGraph <CFGNode, CFGEdge>();
            var ivf   = new IdentifiableVertexFactory <CFGNode>(CFGNode.Factory);
            var ief   = new IdentifiableEdgeFactory <CFGNode, CFGEdge>(CFGEdge.Factory);

            using (var reader = XmlReader.Create(path))
            {
                deser.Deserialize(reader, graph, ivf, ief);
            }
            ReplaceLineBreaks(graph, false);
            return(graph);
        }
Esempio n. 10
0
        /// <summary>
        /// Deserializes the given file at <paramref name="filePath"/> (GraphML graph) into the given <paramref name="graph"/>.
        /// </summary>
        /// <typeparam name="TVertex">Vertex type.</typeparam>
        /// <typeparam name="TEdge">Edge type.</typeparam>
        /// <typeparam name="TGraph">Graph type.</typeparam>
        /// <param name="graph">Graph instance to fill.</param>
        /// <param name="filePath">Path to the file to load.</param>
        /// <param name="vertexFactory">Vertex factory method.</param>
        /// <param name="edgeFactory">Edge factory method.</param>
        public static void DeserializeFromGraphML <TVertex, TEdge, TGraph>(
            [NotNull] this TGraph graph,
            [NotNull] string filePath,
            [NotNull] IdentifiableVertexFactory <TVertex> vertexFactory,
            [NotNull] IdentifiableEdgeFactory <TVertex, TEdge> edgeFactory)
            where TEdge : IEdge <TVertex>
            where TGraph : IMutableVertexAndEdgeListGraph <TVertex, TEdge>
        {
            if (string.IsNullOrEmpty(filePath))
            {
                throw new ArgumentException("Must provide a file path.", nameof(filePath));
            }

            using (var reader = new StreamReader(filePath))
                DeserializeFromGraphML(graph, reader, vertexFactory, edgeFactory);
        }
Esempio n. 11
0
            public ReaderWorker(
                [NotNull] XmlReader reader,
                [NotNull] TGraph graph,
                [NotNull] IdentifiableVertexFactory <TVertex> vertexFactory,
                [NotNull] IdentifiableEdgeFactory <TVertex, TEdge> edgeFactory)
            {
                Debug.Assert(reader != null);
                Debug.Assert(graph != null);
                Debug.Assert(vertexFactory != null);
                Debug.Assert(edgeFactory != null);

                _reader        = reader;
                _graph         = graph;
                _vertexFactory = vertexFactory;
                _edgeFactory   = edgeFactory;
            }
        public static void DeserializeFromGraphML <TVertex, TEdge, TGraph>(
            this TGraph graph, XmlReader reader,
            IdentifiableVertexFactory <TVertex> vertexFactory,
            IdentifiableEdgeFactory <TVertex, TEdge> edgeFactory
            )
            where TEdge : IEdge <TVertex>
            where TGraph : IMutableVertexAndEdgeListGraph <TVertex, TEdge>
        {
            Contract.Requires(graph != null);
            Contract.Requires(reader != null);
            Contract.Requires(vertexFactory != null);
            Contract.Requires(edgeFactory != null);

            var serializer = new GraphMLDeserializer <TVertex, TEdge, TGraph>();

            serializer.Deserialize(reader, graph, vertexFactory, edgeFactory);
        }
Esempio n. 13
0
        /// <summary>
        /// Deserializes from the given <paramref name="reader"/> (GraphML graph) into the given <paramref name="graph"/>
        /// and checks if content is valid.
        /// </summary>
        /// <typeparam name="TVertex">Vertex type.</typeparam>
        /// <typeparam name="TEdge">Edge type.</typeparam>
        /// <typeparam name="TGraph">Graph type.</typeparam>
        /// <param name="graph">Graph instance to fill.</param>
        /// <param name="reader">Reader stream.</param>
        /// <param name="vertexFactory">Vertex factory method.</param>
        /// <param name="edgeFactory">Edge factory method.</param>
        /// <exception cref="T:System.ArgumentNullException"><paramref name="graph"/> is <see langword="null"/>.</exception>
        /// <exception cref="T:System.ArgumentNullException"><paramref name="reader"/> is <see langword="null"/>.</exception>
        /// <exception cref="T:System.ArgumentNullException"><paramref name="vertexFactory"/> is <see langword="null"/>.</exception>
        /// <exception cref="T:System.ArgumentNullException"><paramref name="edgeFactory"/> is <see langword="null"/>.</exception>
        /// <exception cref="T:System.InvalidOperationException">Deserializing value on property without setter, or with invalid default value.</exception>
        /// <exception cref="T:System.InvalidOperationException"><see cref="XmlConstants.GraphMLTag"/> or <see cref="XmlConstants.GraphTag"/> not found.</exception>
        /// <exception cref="T:System.InvalidOperationException">Failure while reading elements from GraphML.</exception>
        /// <exception cref="T:System.NotSupportedException">Deserializing graph with unsupported property type.</exception>
        public static void DeserializeAndValidateFromGraphML <TVertex, TEdge, TGraph>(
            [NotNull] this TGraph graph,
            [NotNull] TextReader reader,
            [NotNull] IdentifiableVertexFactory <TVertex> vertexFactory,
            [NotNull] IdentifiableEdgeFactory <TVertex, TEdge> edgeFactory)
            where TEdge : IEdge <TVertex>
            where TGraph : IMutableVertexAndEdgeSet <TVertex, TEdge>
        {
            if (reader is null)
            {
                throw new ArgumentNullException(nameof(reader));
            }

            var serializer = new GraphMLDeserializer <TVertex, TEdge, TGraph>();

            var resolver = new GraphMLXmlResolver();
            var settings = new XmlReaderSettings
            {
                ValidationType = ValidationType.Schema,
                XmlResolver    = resolver,
                DtdProcessing  = DtdProcessing.Ignore
            };

            settings.ValidationFlags |= XmlSchemaValidationFlags.ProcessInlineSchema;
            settings.ValidationFlags |= XmlSchemaValidationFlags.ProcessSchemaLocation;
            settings.ValidationFlags |= XmlSchemaValidationFlags.ReportValidationWarnings;

            // Add GraphML schema
            AddGraphMLSchema(settings, resolver);

            try
            {
                settings.ValidationEventHandler += ValidationEventHandler;

                // Read and validate
                using (XmlReader xmlReader = XmlReader.Create(reader, settings))
                {
                    serializer.Deserialize(xmlReader, graph, vertexFactory, edgeFactory);
                }
            }
            finally
            {
                settings.ValidationEventHandler -= ValidationEventHandler;
            }
        }
        public static void DeserializeAndValidateFromGraphML <TVertex, TEdge, TGraph>(
#if !NET20
            this
#endif
            TGraph graph,
            TextReader reader,
            IdentifiableVertexFactory <TVertex> vertexFactory,
            IdentifiableEdgeFactory <TVertex, TEdge> edgeFactory
            )
            where TEdge : IEdge <TVertex>
            where TGraph : IMutableVertexAndEdgeListGraph <TVertex, TEdge>
        {
            Contract.Requires(graph != null);
            Contract.Requires(reader != null);
            Contract.Requires(vertexFactory != null);
            Contract.Requires(edgeFactory != null);

            DeserializeAndValidateFromGraphML(graph, XmlReader.Create(reader), vertexFactory, edgeFactory);
        }
Esempio n. 15
0
        public static void DeserializeFromGraphML <TVertex, TEdge, TGraph>(
#if !NET20
            this
#endif
            TGraph graph,
            string fileName,
            IdentifiableVertexFactory <TVertex> vertexFactory,
            IdentifiableEdgeFactory <TVertex, TEdge> edgeFactory
            )
            where TEdge : IEdge <TVertex>
            where TGraph : IMutableVertexAndEdgeListGraph <TVertex, TEdge>
        {
            Contract.Requires(fileName != null);
            Contract.Requires(fileName.Length > 0);

            var reader = new StreamReader(fileName);

            DeserializeFromGraphML <TVertex, TEdge, TGraph>(graph, reader, vertexFactory, edgeFactory);
        }
        public void Deserialize(
            XmlReader reader,
            TGraph visitedGraph,
            IdentifiableVertexFactory <TVertex> vertexFactory,
            IdentifiableEdgeFactory <TVertex, TEdge> edgeFactory)
        {
            Contract.Requires(reader != null);
            Contract.Requires(visitedGraph != null);
            Contract.Requires(vertexFactory != null);
            Contract.Requires(edgeFactory != null);

            var worker = new ReaderWorker(
                this,
                reader,
                visitedGraph,
                vertexFactory,
                edgeFactory);

            worker.Deserialize();
        }
            public ReaderWorker(
                GraphMLDeserializer <TVertex, TEdge, TGraph> serializer,
                XmlReader reader,
                TGraph visitedGraph,
                IdentifiableVertexFactory <TVertex> vertexFactory,
                IdentifiableEdgeFactory <TVertex, TEdge> edgeFactory
                )
            {
                Contract.Requires(serializer != null);
                Contract.Requires(reader != null);
                Contract.Requires(visitedGraph != null);
                Contract.Requires(vertexFactory != null);
                Contract.Requires(edgeFactory != null);

                this.serializer    = serializer;
                this.reader        = reader;
                this.visitedGraph  = visitedGraph;
                this.vertexFactory = vertexFactory;
                this.edgeFactory   = edgeFactory;
            }
Esempio n. 18
0
        /// <summary>
        /// Deserializes from the given <paramref name="reader"/> (GraphML graph) into the given <paramref name="graph"/>.
        /// </summary>
        /// <typeparam name="TVertex">Vertex type.</typeparam>
        /// <typeparam name="TEdge">Edge type.</typeparam>
        /// <typeparam name="TGraph">Graph type.</typeparam>
        /// <param name="graph">Graph instance to fill.</param>
        /// <param name="reader">Reader stream.</param>
        /// <param name="vertexFactory">Vertex factory method.</param>
        /// <param name="edgeFactory">Edge factory method.</param>
        public static void DeserializeFromGraphML <TVertex, TEdge, TGraph>(
            [NotNull] this TGraph graph,
            [NotNull] TextReader reader,
            [NotNull] IdentifiableVertexFactory <TVertex> vertexFactory,
            [NotNull] IdentifiableEdgeFactory <TVertex, TEdge> edgeFactory)
            where TEdge : IEdge <TVertex>
            where TGraph : IMutableVertexAndEdgeListGraph <TVertex, TEdge>
        {
            if (reader is null)
            {
                throw new ArgumentNullException(nameof(reader));
            }

            var settings = new XmlReaderSettings
            {
                ValidationFlags = XmlSchemaValidationFlags.None,
                XmlResolver     = new GraphMLXmlResolver()
            };

            using (XmlReader xmlReader = XmlReader.Create(reader, settings))
                DeserializeFromGraphML(graph, xmlReader, vertexFactory, edgeFactory);
        }
        /// <summary>
        /// Deserializes from the given <paramref name="reader"/> (GraphML graph) into the given <paramref name="graph"/>
        /// and checks if content is valid.
        /// </summary>
        /// <typeparam name="TVertex">Vertex type.</typeparam>
        /// <typeparam name="TEdge">Edge type.</typeparam>
        /// <typeparam name="TGraph">Graph type.</typeparam>
        /// <param name="graph">Graph instance to fill.</param>
        /// <param name="reader">Reader stream.</param>
        /// <param name="vertexFactory">Vertex factory method.</param>
        /// <param name="edgeFactory">Edge factory method.</param>
        public static void DeserializeAndValidateFromGraphML <TVertex, TEdge, TGraph>(
            this TGraph graph,
            TextReader reader,
            IdentifiableVertexFactory <TVertex> vertexFactory,
            IdentifiableEdgeFactory <TVertex, TEdge> edgeFactory)
            where TEdge : IEdge <TVertex>
            where TGraph : IMutableVertexAndEdgeListGraph <TVertex, TEdge>
        {
            if (reader is null)
            {
                throw new ArgumentNullException(nameof(reader));
            }

            var serializer = new GraphMLDeserializer <TVertex, TEdge, TGraph>();

            var settings = new XmlReaderSettings
            {
                ValidationType = ValidationType.Schema,
                XmlResolver    = new GraphMLXmlResolver(),
                DtdProcessing  = DtdProcessing.Ignore
            };

            // Add GraphML schema
            AddGraphMLSchema(settings);

            try
            {
                settings.ValidationEventHandler += ValidationEventHandler;

                // Read and validate
                using (XmlReader xmlReader = XmlReader.Create(reader, settings))
                    serializer.Deserialize(xmlReader, graph, vertexFactory, edgeFactory);
            }
            finally
            {
                settings.ValidationEventHandler -= ValidationEventHandler;
            }
        }