Exemplo n.º 1
0
        TryGetGraphFromGraphDataProvider
        (
            Object graphDataProvider,
            out IGraph graph
        )
        {
            Debug.Assert(graphDataProvider != null);

            Debug.Assert(graphDataProvider is IGraphDataProvider2 ||
                         graphDataProvider is IGraphDataProvider);

            graph = null;
            GraphMLGraphAdapter oGraphMLGraphAdapter = new GraphMLGraphAdapter();

            if (graphDataProvider is IGraphDataProvider2)
            {
                String sPathToTemporaryFile = null;

                if (!((IGraphDataProvider2)graphDataProvider)
                    .TryGetGraphDataAsTemporaryFile(out sPathToTemporaryFile))
                {
                    return(false);
                }

                try
                {
                    graph = oGraphMLGraphAdapter.LoadGraphFromFile(
                        sPathToTemporaryFile);
                }
                finally
                {
                    File.Delete(sPathToTemporaryFile);
                }
            }
            else
            {
                String sGraphDataAsGraphML;

                if (!((IGraphDataProvider)graphDataProvider).TryGetGraphData(
                        out sGraphDataAsGraphML))
                {
                    return(false);
                }

                graph = oGraphMLGraphAdapter.LoadGraphFromString(
                    sGraphDataAsGraphML);
            }

            return(true);
        }
Exemplo n.º 2
0
        OpenObject
        (
            String sFileName,
            out Object oObject
        )
        {
            Debug.Assert(!String.IsNullOrEmpty(sFileName));
            Debug.Assert(File.Exists(sFileName));
            AssertValid();

            oObject = null;

            // Use a graph adapter to create a graph from the file.

            IGraphAdapter oGraphMLGraphAdapter = new GraphMLGraphAdapter();

            oObject = oGraphMLGraphAdapter.LoadGraphFromFile(sFileName);
        }