public virtual void OnFlush(IThingGraph graph)
 {
     if (ThingGraphIo != null)
     {
         if (ThingGraphIo.IoMode == IoMode.Write)
         {
             ThingGraphIo.Flush(GraphContent);
         }
     }
 }
        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);
        }