예제 #1
0
 public virtual void Close()
 {
     if (ThingGraphIo != null)
     {
         ThingGraphIo.Close(GraphContent);
         this.GraphContent = null;
     }
 }
예제 #2
0
 public static string Extension(this ThingGraphIo source)
 {
     if (source.Detector == null || !source.Detector.ContentSpecs.Any())
     {
         return(".<null>");
     }
     return("." + source.Detector.ContentSpecs.First().Extension);
 }
예제 #3
0
 public virtual void OnFlush(IThingGraph graph)
 {
     if (ThingGraphIo != null)
     {
         if (ThingGraphIo.IoMode == IoMode.Write)
         {
             ThingGraphIo.Flush(GraphContent);
         }
     }
 }
예제 #4
0
 public virtual ThingGraphContent CreateGraphContent(Iori iori)
 {
     if (ThingGraphIo != null)
     {
         var result = ThingGraphIo.Open(iori);
         ReportDetail("*** file:\t" + iori.Name + ThingGraphIo.Extension());
         return(result);
     }
     return(new ThingGraphContent {
         Data = new ThingGraph()
     });
 }
예제 #5
0
        public bool SaveAs(Iori iori)
        {
            // save current:
            var          oldSource = "";
            ThingGraphIo sinkIo    = null;

            if (Data.Source != null)
            {
                oldSource = this.Data.Source.ToString();

                sinkIo = ThingGraphIoManager.GetSinkIO(Data.ContentType, IoMode.Write) as ThingGraphIo;
                if (sinkIo != null)
                {
                    sinkIo.Flush(Data);
                }
            }

            // get the new:
            sinkIo = ThingGraphIoManager.GetSinkIO(iori, IoMode.Write) as ThingGraphIo;
            if (sinkIo == null)
            {
                return(false);
            }
            var sink = sinkIo.Open(iori);

            // saveAs:
            var merger = new ThingGraphMerger {
                Progress = this.Progress
            };

            merger.Use(Data.Data, sink.Data);
            merger.AttachThings(sink.Data);

            // close and reopen; flush and attach does't work in all cases
            sinkIo.Close(sink);
            sink = sinkIo.Open(iori);

            AttachCurrent(sink, iori.Name);

            OnProgress(string.Format("{0} saved as {1}", Path.GetFileNameWithoutExtension(oldSource), iori.Name), -1, -1);
            return(true);
        }