Example #1
0
        protected IGraphScene <IVisual, IVisualEdge> LoadFromStream(Stream source, IGraph <IVisual, IVisualEdge> sourceGraph, IGraphSceneLayout <IVisual, IVisualEdge> layout)
        {
            if (source == null || sourceGraph == null)
            {
                return(null);
            }

            try {
                sourceGraph.CheckLayout(layout);

                source.Position = 0;

                var scene = Mesh.CreateSinkScene(sourceGraph);
                layout = scene.CloneLayout(layout);

                var visuals = new SheetSerializer().Read(source, scene.Graph, layout);

                new GraphSceneFacade <IVisual, IVisualEdge> (() => scene, layout)
                .Add(visuals, true, false);

                source.Position = 0;

                return(scene);
            } catch (Exception ex) {
                // TODO: stream-closed-error should never happen.Try to get reread the source
                Registry.Pooled <IExceptionHandler> ().Catch(ex, MessageType.OK);
            }
            return(null);
        }