Ejemplo n.º 1
0
            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;
            }
Ejemplo n.º 2
0
        public static void DeserializeFromGraphML <TVertex, TEdge, TGraph>(
#if !NET20
            this
#endif
            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);
        }
Ejemplo n.º 3
0
        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);

            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);
            }
        }