Esempio n. 1
0
        public static Graph GetGraphInstance(string resourcePath, IFileProvider fileProvider, ExternalRessourcesLoadingPolicy loadingPolicy)
        {
            GraphXmlDeserializer parser = new GraphXmlDeserializer()
            {
                localFileProvider = fileProvider, FileLoadingPolicy = loadingPolicy
            };

            return(parser.LoadFile(resourcePath));
        }
Esempio n. 2
0
        public static Graph GetGraphInstance(string resourcePath, IFileProvider fileProvider, Type vertexImplementation)
        {
            GraphXmlDeserializer parser = new GraphXmlDeserializer()
            {
                localFileProvider = fileProvider, FileLoadingPolicy = ExternalRessourcesLoadingPolicy.None
            };

            parser.OverrideConcreteVertexype(vertexImplementation);
            return(parser.LoadFile(resourcePath));
        }
Esempio n. 3
0
        public static Graph LoadMultipleFiles(IEnumerable <string> resourcePaths, IFileProvider fileProvider, ExternalRessourcesLoadingPolicy loadingPolicy)
        {
            if (fileProvider == null)
            {
                throw new NullReferenceException("FileProvider implementation is not specified.");
            }
            IEnumerable <StreamReader> streams = new List <StreamReader>();

            streams = resourcePaths.Select(p => fileProvider.GetFileReader(p));

            List <GraphXmlDeserializer> deserializers = new List <GraphXmlDeserializer>();

            foreach (StreamReader stream in streams)
            {
                XDocument xdoc = XDocument.Load(stream);
                stream.Close();
                GraphXmlDeserializer gds = new GraphXmlDeserializer();
                gds.ParseFile(xdoc);
                deserializers.Add(gds);
            }

            GraphXmlDeserializer main = deserializers[0];

            for (int i = 1; i < deserializers.Count; i++)
            {
                main.Merge(deserializers[i]);
            }
            main.ResolveExternalEdges();
            main.ResolveAnnotationDeclarations();

            Graph g = new Graph();

            foreach (IVertex v in main.vertexInstances.Values)
            {
                g.AddVertex(v);
            }
            foreach (var annotationPair in main.annotationsTable)
            {
                IGraphObject target = g.GetElementById(annotationPair.Key);
                g.AddAnnotations(target, annotationPair.Value);
            }

            return(g);
        }
Esempio n. 4
0
        public static AnnotationList LoadAnnotationListFromXml(XDocument xml)
        {
            GraphXmlDeserializer deserializer = new GraphXmlDeserializer();

            return(deserializer.LoadAnnotationListFromXmlPrivate(xml));
        }
Esempio n. 5
0
        public static Graph LoadFromXml(XDocument xml)
        {
            GraphXmlDeserializer deserializer = new GraphXmlDeserializer();

            return(deserializer.LoadGraph(xml));
        }
 private void Merge(GraphXmlDeserializer otherDeserializer)
 {
     vertexInstances        = vertexInstances.Union(otherDeserializer.vertexInstances).ToDictionary(k => k.Key, v => v.Value);
     edgesDeclarations      = new HashSet <EdgeInfo>(edgesDeclarations.Union(otherDeserializer.edgesDeclarations));
     annotationDeclarations = annotationDeclarations.Union(otherDeserializer.annotationDeclarations).ToList();
 }