public IGraphScene <IVisual, IVisualEdge> LoadFromContent(Content <Stream> source, IGraph <IVisual, IVisualEdge> sourceGraph, IGraphSceneLayout <IVisual, IVisualEdge> layout) { var result = default(IGraphScene <IVisual, IVisualEdge>); try { var name = string.Empty; if (source.Description != null) { name = source.Description.ToString(); } Int64 id = 0; if (source.Source is Int64) { id = (Int64)source.Source; } result = LoadFromStream(source.Data, sourceGraph, layout); if (result != null) { result.State.Clean = true; result.State.Hollow = false; var info = SheetStore.RegisterSceneInfo(id, name); result.State.CopyTo(info.State); } } finally { } return(result); }
protected SceneInfo SaveToThing(IGraphScene <IVisual, IVisualEdge> scene, IGraphSceneLayout <IVisual, IVisualEdge> layout, IThing thing, string name) { var result = default(SceneInfo); if (thing is IStreamThing || thing == null) { var content = new Content <Stream> ( new MemoryStream(), CompressionType.bZip2, ContentTypes.LimadaSheet); var serializer = new SheetSerializer(); serializer.Save(content.Data, scene.Graph, layout); content.Data.Position = 0; content.Description = name; thing = new VisualThingsContentViz().AssignContent(scene.Graph, thing, content); result = SheetStore.RegisterSceneInfo(thing.Id, name); result.State.Hollow = false; result.State.Clean = true; result.State.CopyTo(scene.State); } else { throw new ArgumentException("thing must be a StreamThing"); } return(result); }
public Stream StreamFromStore(long id) { byte [] buffer = null; try { if (SheetStore.TryGetValue(id, out buffer)) { return(new MemoryStream(buffer)); } } 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); }
public bool SaveInStore(IGraphScene <IVisual, IVisualEdge> scene, IGraphSceneLayout <IVisual, IVisualEdge> layout, long id) { if (scene.Graph.Count > 0) { var stream = new MemoryStream(); new SheetSerializer().Save(stream, scene.Graph, layout); stream.Position = 0; SheetStore.Add(id, stream.GetBuffer((int)stream.Length)); return(true); } SheetStore.Remove(id); return(false); }
public IGraphScene <IVisual, IVisualEdge> LoadFromStore(IGraph <IVisual, IVisualEdge> source, IGraphSceneLayout <IVisual, IVisualEdge> layout, Int64 id) { byte [] buffer = null; try { if (SheetStore.TryGetValue(id, out buffer)) { // save state of store: var info = SheetStore.GetSheetInfo(id); var state = info.State.Clone(); var result = LoadFromStream(new MemoryStream(buffer), source, layout); state.CopyTo(info.State); state.CopyTo(result.State); return(result); } } 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); }
public void Clear() { SheetStore.Clear(); }