Exemplo n.º 1
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);
        }
Exemplo n.º 2
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()
     });
 }