Esempio n. 1
0
        public bool Open(Iori iori)
        {
            ThingGraphContent source = null;
            var sinkIo = ThingGraphIoManager.GetSinkIO(iori, IoMode.Read) as ThingGraphIo;

            try {
                // TODO: check if iori already in use

                source = sinkIo.Open(iori);
                OnProgress("", -1, -1);
                AttachCurrent(source, iori.Name);
                return(true);
            } catch (Exception ex) {
                Registry.Pooled <IExceptionHandler>()
                .Catch(new Exception("Open failed: " + ex.Message, ex), MessageType.OK);
                try {
                    if (source != null)
                    {
                        sinkIo.Close(source);
                    }
                } catch { }

                return(false);
            }
        }
Esempio n. 2
0
        protected override ThingGraphContent OpenInternal(Iori source)
        {
            var gateway = new Limaki.Data.db4o.Gateway();

            try {
                gateway.Open(source);

                var sink = new ThingGraphContent {
                    Data        = new ThingGraph(gateway),
                    Source      = source,
                    ContentType = Db4oThingGraphSpot.Db4oThingGraphContentType,
                };
                return(sink);
            } catch (DatabaseFileLockedException ex) {
                throw;
            } catch (Exception ex) {
                if (ex.InnerException != null && ex.InnerException is DatabaseFileLockedException)
                {
                    throw ex.InnerException;
                }
                else
                {
                    var olderVersion = ProveIfOlderVersion(gateway);
                    if (olderVersion != null)
                    {
                        throw new NotSupportedException(olderVersion, ex);
                    }
                    else
                    {
                        throw;
                    }
                }
            }
        }
        public virtual GraphSceneDisplayMemento ReadDisplay(XElement node)
        {
            var memento = new GraphSceneDisplayMemento();

            var iori = ReadElement(node, NodeNames.Source);

            if (iori != null)
            {
                memento.Iori = Iori.FromFileName(Read <string> (iori, NodeNames.File));
            }

            memento.Info = new SceneInfoXmlSerializer().ReadSceneInfo(node);;

            var vp = ReadElement(node, NodeNames.Viewport);

            memento.Offset    = Read <Point> (vp, NodeNames.Offset);
            memento.ZoomState = Read <ZoomState> (vp, NodeNames.ZoomState);
            memento.Zoom      = Read <double> (vp, NodeNames.Zoom);

            var thingGraph = Mesh.BackGraph(memento.Iori);

            memento.Scene = Mesh.BackHandler <IThing, ILink>().CreateScene(thingGraph);

            var layout = ReadElement(node, NodeNames.Layout);

            memento.StyleSheetName = Read <string> (layout, NodeNames.StyleSheet);
            var styleSheet = Registry.Pooled <StyleSheets> ()[memento.StyleSheetName];

            // NEVER use the tempLayout in memento-Layout; this brings troubles if data changes
            // creating layout is done in memento.Restore
            Func <IGraphScene <IVisual, IVisualEdge> > scene = () => memento.Scene;
            var tempLayout = Registry.Create <IGraphSceneLayout <IVisual, IVisualEdge> > (scene, styleSheet);

            var serializer = new VisualThingXmlSerializer();

            serializer.VisualThingGraph = memento.Scene.Graph.Source <IVisual, IVisualEdge, IThing, ILink> ();
            serializer.Layout           = tempLayout;

            serializer.XThings = ReadElement(node, VisualThingXmlSerializer.NodeNames.Things);

            serializer.ReadXThings();

            new GraphSceneFacade <IVisual, IVisualEdge> (() => memento.Scene, tempLayout)
            .Add(serializer.VisualsCollection, true, false);

            var sceneDetails = ReadElement(node, NodeNames.Scene);
            var foc          = Read <long> (sceneDetails, NodeNames.Focused);

            if (foc != 0)
            {
                var focThing = thingGraph.GetById(foc);
                if (focThing != null)
                {
                    memento.Scene.Focused = memento.Scene.Graph.VisualOf(focThing);
                }
            }
            memento.Scene.ClearSpatialIndex();

            return(memento);
        }
Esempio n. 4
0
        public void ContentProviders()
        {
            Iori input = null;
            IPipe <Iori, Stream> file = null;
            IPipe <Stream, Content <Stream> > contentProvider   = null;
            IPipe <Iori, Content <Stream> >   contentIoProvider = null;

            IPipe <Content <Stream>, IThing> contentThingProvider = null;
        }
Esempio n. 5
0
        public void GraphProviders()
        {
            Iori input = null;
            IPipe <Iori, Stream>        file = null;
            IPipe <Stream, IThingGraph> thingGraphProvider = null;
            IPipe <IThingGraph, IGraphScene <IVisual, IVisualEdge> > sceneProvider = null;

            var scene = sceneProvider.Use(thingGraphProvider.Use(file.Use(input)));
        }
Esempio n. 6
0
        public void ImportRawSource()
        {
            Save();
            Close(Data);
            bool tryIt = true;

            while (tryIt && MessageBoxShow("Open a new, non exisiting file", "RawImport", MessageBoxButtons.OkCancel) == DialogResult.Ok)
            {
                var fileDialog = new FileDialogMemento();
                DefaultDialogValues(fileDialog, WriteFilter);
                DefaultDialogValues(OpenFileDialog, ReadFilter);

                if (FileDialogShow(fileDialog, true) == DialogResult.Ok)
                {
                    var sinkFile = fileDialog.FileName;
                    fileDialog.ResetFileName();
                    if (File.Exists(sinkFile))
                    {
                        continue;
                    }
                    if (tryIt = MessageBoxShow("Open the file to import", "RawImport", MessageBoxButtons.OkCancel) == DialogResult.Ok)
                    {
                        if (FileDialogShow(OpenFileDialog, true) == DialogResult.Ok)
                        {
                            var sourceFile = OpenFileDialog.FileName;
                            if (!File.Exists(sourceFile))
                            {
                                MessageBoxShow("File does not exist", "RawImport", MessageBoxButtons.Ok);
                                break;
                            }

                            tryIt = false;
                            var sourceInfo         = Iori.FromFileName(sourceFile);
                            var sinkIo             = ThingGraphIoManager.GetSinkIO(Iori.FromFileName(sinkFile), IoMode.Write) as ThingGraphIo;
                            ThingGraphContent sink = null;

                            try {
                                sink = sinkIo.Open(Iori.FromFileName(sinkFile));
                                var repairer = Registry.Pooled <ThingGraphRepairPool>()
                                               .Find(sourceInfo.Extension, IoMode.Read) as IPipe <Iori, IThingGraph>;
                                this.AttachProgress(repairer as IProgress);
                                repairer.Use(Iori.FromFileName(sourceFile), sink.Data);
                            } catch (Exception ex) {
                                Registry.Pooled <IExceptionHandler>()
                                .Catch(new Exception("Raw import failed: " + ex.Message, ex), MessageType.OK);
                                sinkIo.Close(sink);
                                File.Delete(sinkFile);
                            }
                            sinkIo.Close(sink);
                            MessageBoxShow("Import successfull", "RawImport", MessageBoxButtons.Ok);
                            this.Open(Iori.FromFileName(sinkFile));
                            OpenFileDialog.ResetFileName();
                        }
                    }
                }
            }
        }
Esempio n. 7
0
 public void Close()
 {
     if (Current != null)
     {
         Close(Current);
         Trace.WriteLine(string.Format("DataBase closed {0}", Iori.ToFileName()));
         Current = null;
     }
 }
Esempio n. 8
0
 public void SaveAs()
 {
     DefaultDialogValues(SaveFileDialog, WriteFilter);
     SaveFileDialog.OverwritePrompt = false;
     if (FileDialogShow(SaveFileDialog, false) == DialogResult.Ok)
     {
         SaveAs(Iori.FromFileName(SaveFileDialog.FileName));
         SaveFileDialog.ResetFileName();
     }
 }
Esempio n. 9
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()
     });
 }
Esempio n. 10
0
        public static IThingGraph OpenGraph(Iori iori)
        {
            if (iori == null)
            {
                return(null);
            }

            var io = new ThingGraphIoManager().GetSinkIO(iori, IoMode.Read) as ThingGraphIo;

            var ct = io.Open(iori);

            return(ct.Data);
        }
Esempio n. 11
0
 public void ExportSceneView(IGraphScene <IVisual, IVisualEdge> scene)
 {
     DefaultDialogValues(SaveFileDialog, WriteFilter);
     if (scene != null && scene.HasThingGraph())
     {
         SaveFileDialog.OverwritePrompt = false;
         if (FileDialogShow(SaveFileDialog, false) == DialogResult.Ok)
         {
             ExportSceneView(Iori.FromFileName(SaveFileDialog.FileName), scene);
             SaveFileDialog.ResetFileName();
         }
     }
 }
Esempio n. 12
0
        public void IntGraphTest()
        {
            Gateway.Open(Iori.FromFileName(FileName));
            var graphTest = new IntGraphTest();

            Limaki.Data.db4o.Graph <int, Edge <int> >
            graph = new Limaki.Data.db4o.Graph <int, Edge <int> > (Gateway);

            graphTest.Graph = graph;
            graphTest.Setup();
            graphTest.AllTests();
            graph.Clear();
            Gateway.Close();
        }
Esempio n. 13
0
        public void EdgeIsItemTest()
        {
            Gateway.Open(Iori.FromFileName(FileName));
            var graphTest = new EdgeIsItemGraphTest();

            Limaki.Data.db4o.Graph <Item <string>, EdgeItem <string> >
            graph = new Limaki.Data.db4o.Graph <Item <string>, EdgeItem <string> >(Gateway);

            graphTest.Graph = graph;
            graphTest.Setup();
            graphTest.AllTests();
            graph.Clear();
            Gateway.Close();
        }
Esempio n. 14
0
        protected void GetAppSettings(Iori iori)
        {
            var appSettings = AppSettingsGetter();//;

            for (int i = 0; i < appSettings.Count; i++)
            {
                string key  = appSettings.GetKey(i);
                string data = appSettings.Get(i);

                if (key == "DataBaseFileName")
                {
                    if (Path.GetDirectoryName(data) == "")
                    {
                        data = ApplicationPhysicalPath + Path.DirectorySeparatorChar + data;
                    }
                    IoriExtensions.FromFileName(iori, data);
                }

                if (key == "DataBaseServer")
                {
                    iori.Server = data;
                }
                if (key == "DataBaseName")
                {
                    iori.Name = data;
                }
                if (key == "DataBasePath")
                {
                    iori.Path = data;
                }
                if (key == "DataBaseUser")
                {
                    iori.User = data;
                }
                if (key == "DataBasePassword")
                {
                    iori.Password = data;
                }
                if (key == "DataBaseProvider")
                {
                    iori.Provider = data;
                }

                if (key == "SiteName")
                {
                    SiteName = data;
                }
            }
        }
Esempio n. 15
0
        public void StringGraphTest()
        {
            var graphTest = new StringGraphTest();

            Gateway.Open(Iori.FromFileName(FileName));
            Limaki.Data.db4o.Graph <string, Edge <string> > graph =
                new Limaki.Data.db4o.Graph <string, Edge <string> > (Gateway);

            graphTest.Graph = graph;
            graphTest.Setup();
            graphTest.AllTests();
            graph.Clear();

            Gateway.Close();
        }
Esempio n. 16
0
 public void ExportSceneView(Iori iori, IGraphScene <IVisual, IVisualEdge> scene)
 {
     if (scene.HasThingGraph())
     {
         var sinkIo = ThingGraphIoManager.GetSinkIO(iori, IoMode.Write) as ThingGraphIo;
         if (sinkIo != null)
         {
             var source = Registry.Create <ISceneViz <IVisual, IThing, IVisualEdge, ILink> > ()
                          .CreateThingsView(scene);
             var sink = sinkIo.Open(iori);
             new ThingGraphExporter {
                 Progress = this.Progress
             }.Use(source, sink.Data);
             sinkIo.Close(sink);
         }
     }
 }
Esempio n. 17
0
        public override string ToString()
        {
            return($@"
Version: {Version}

{Company} 
{Copyright}

ToolKitType: {ToolKitType ?? ""}

Database: {Iori?.ToString() ?? ""}

Credits: 

{Credits}
");
        }
Esempio n. 18
0
        public void BenchmarkOneTest()
        {
            var sceneFactory =
                new BenchmarkOneGraphFactory <IGraphEntity, IGraphEdge> ();

            Gateway.Open(Iori.FromFileName(FileName));

            var graph =
                new Limaki.Data.db4o.Graph <IGraphEntity, IGraphEdge>(Gateway);

            sceneFactory.Count = 10;

            sceneFactory.Populate(graph);
            //graph.Clear();
            Gateway.Close();
            ReportSummary();
        }
Esempio n. 19
0
        public void Open()
        {
            if (this.IsUnsaved(this.Data))
            {
                if (MessageBoxShow("You have an unsaved document. Do you want to save it?", "", MessageBoxButtons.YesNo) ==
                    DialogResult.Yes)
                {
                    SaveAs();
                }
            }

            DefaultDialogValues(OpenFileDialog, ReadFilter);
            if (FileDialogShow(OpenFileDialog, true) == DialogResult.Ok)
            {
                Open(Iori.FromFileName(OpenFileDialog.FileName));
                OpenFileDialog.ResetFileName();
            }
        }
Esempio n. 20
0
        protected override ThingGraphContent OpenInternal(Iori source)
        {
            Iori sourceInfo = null;

            using (var file = File.OpenRead(source.ToFileName())) {
                sourceInfo = Read(file);
                if (sourceInfo != null)
                {
                    if (string.IsNullOrEmpty(sourceInfo.Path))
                    {
                        sourceInfo.Path = source.Path;
                    }
                }
            }
            var sinkIo        = ThingGraphIoManager.GetSinkIO(sourceInfo, IoMode.Read) as ThingGraphIo;
            var sourceContent = sinkIo.Open(sourceInfo);

            return(sourceContent);
        }
Esempio n. 21
0
        public bool ImportFiles(IEnumerable <string> sourceFiles)
        {
            var result = true;

            if (sourceFiles.Count() > 0)
            {
                var progressSaved   = this.Progress;
                var progressHandler = Registry.Pooled <IProgressHandler> ();
                this.Progress = (m, i, max) => progressHandler.Write(m, i, max);
                try {
                    foreach (var sourceFile in sourceFiles)
                    {
                        if (File.Exists(sourceFile))
                        {
                            progressHandler.Show("Importing file " + sourceFile);
                            var sourceIori = Iori.FromFileName(sourceFile);
                            var sourceIo   = ThingGraphIoManager.GetSinkIO(sourceIori, IoMode.Read) as ThingGraphIo;
                            if (sourceIo != null)
                            {
                                ThingGraphContent source = null;
                                try {
                                    source = sourceIo.Open(sourceIori);
                                    new ThingGraphMerger {
                                        Progress = this.Progress
                                    }.Use(source.Data, Data.Data);
                                } catch (Exception ex) {
                                    Registry.Pooled <IExceptionHandler> ()
                                    .Catch(new Exception("Add file failed: " + ex.Message, ex), MessageType.OK);
                                    result = false;
                                } finally {
                                    sourceIo.Close(source);
                                }
                            }
                        }
                    }
                    Progress = null;
                    progressHandler.Close();
                } finally {
                    Progress = progressSaved;
                }
            }
            return(result);
        }
Esempio n. 22
0
        public virtual void Save(ThingGraphContent source, Iori sinkInfo)
        {
            if (source == null)
            {
                return;
            }

            using (var sink = new FileStream(sinkInfo.ToFileName(), FileMode.Create)) {
                var serializer = new ThingXmlSerializer {
                    Graph = source.Data, Things = source.Data.Elements().ToList()
                };

                serializer.Write(sink);

                sink.Flush();
                sink.Close();
            }
            source.Source = sinkInfo;
        }
Esempio n. 23
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);
        }
Esempio n. 24
0
        public bool OpenCommandLine()
        {
            var    result          = false;
            var    sourceFiles     = new List <string>();
            string fileToOpen      = null;
            string resumeFile      = null;
            var    exitAfterImport = false;

            var p = new OptionSet()
            {
                { "add=", a => sourceFiles.Add(a) },
                { "file=", a => fileToOpen = a },
                { "resume=", a => resumeFile = a },
                { "exit", a => exitAfterImport = a != null },
            };
            var options = p.Parse(Environment.GetCommandLineArgs());

            if (fileToOpen == null)
            {
                if (options.Count > 1)
                {
                    fileToOpen = options[1];
                }
            }

            if (fileToOpen != null && File.Exists(fileToOpen))
            {
                result = Open(Iori.FromFileName(fileToOpen));
            }

            if (result)
            {
                result = ImportFiles(sourceFiles);
            }

            if (exitAfterImport && ApplicationQuit != null)
            {
                ApplicationQuit();
            }
            return(result);
        }
Esempio n. 25
0
        public virtual void TestDocumentWithTestData()
        {
            IThingGraph thingGraph = new ThingGraph();
            var         prov       = new Limada.IO.Db4oThingGraphIo();
            var         d          = prov.Open(Iori.FromFileName(TestLocations.GraphtestDir + "DocumentTest.limo"));

            thingGraph = d.Data;

            this.ReportDetail("**** TestDocumentWithTestData");
            var factory = new DigidocSampleFactory();
            var digidoc = new DigidocSchema();
            var graph   = new SchemaThingGraph(thingGraph);

            Limada.Schemata.Schema.IdentityGraph.ForEach(s => graph.Add(s));

            var root = DigidocSchema.DocumentsRoot;
            var path = TestLocations.BlobSource;

            var document = digidoc.CreateDocument(graph, path);

            graph.Add(Factory.CreateEdge(root, document, DigidocSchema.Document));

            factory.ReadPagesFromDir(graph, document, path);

            var docs = graph.Edges(root).Where(l => l.Marker == DigidocSchema.Document).Select(l => l.Leaf);

            foreach (var doc in docs)
            {
                var title = graph.ThingToDisplay(doc);
                this.ReportDetail(title.ToString());
                var pages = graph.Edges(doc).Where(l => l.Marker == DigidocSchema.DocumentPage).Select(l => l.Leaf);
                foreach (var page in pages)
                {
                    var number = graph.ThingToDisplay(page);
                    Assert.IsNotNull(number);
                    this.ReportDetail(number.ToString());
                }
            }
            prov.Flush(d);
        }
Esempio n. 26
0
 protected override ThingGraphContent OpenInternal(Iori source)
 {
     try {
         IThingGraph thingGraph = null;
         var         fileName   = source.ToFileName();
         if (File.Exists(fileName))
         {
             using (var file = new FileStream(fileName, FileMode.Open))
                 thingGraph = Open(file);
         }
         else
         {
             thingGraph = new ThingGraph();
         }
         return(new ThingGraphContent {
             Data = thingGraph, Source = source, ContentType = XmlThingGraphSpot.ContentType
         });
     } catch (Exception ex) {
         Registry.Pooled <IExceptionHandler>()
         .Catch(new Exception("File load failed: " + ex.Message, ex), MessageType.OK);
     }
     return(null);
 }
Esempio n. 27
0
 public void Open()
 {
     if (Current != null)
     {
         Trace.WriteLine(string.Format("Provider already opened {0}", Current.Description));
         var conn = Current.Data as IGatewayConnection;
         if (conn != null)
         {
             Trace.WriteLine(string.Format("Connection already opened {0}/{1}", conn.Gateway.IsOpen, conn.Gateway.Iori.ToFileName()));
         }
     }
     else
     {
         var ioManager = new ThingGraphIoManager {
         };
         var sinkIo    = ioManager.GetSinkIO(Iori, IoMode.Read) as ThingGraphIo;
         try {
             var sink = sinkIo.Open(Iori);
             if (sink != null)
             {
                 Trace.WriteLine(string.Format("DataBase opened {0}", Iori.ToFileName()));
                 Current = sink;
                 var graph = new SchemaThingGraph(Current.Data);
                 PrepareGraph(graph);
                 _thingGraph = graph;
             }
             else
             {
                 throw new Exception("Database not found: " + Iori.ToString());
             }
         } catch (Exception e) {
             Trace.WriteLine(e.Message);
             _thingGraph = new ThingGraph();
             Trace.WriteLine(string.Format("Empty Graph created {0}", Iori.ToFileName()));
         }
     }
 }
Esempio n. 28
0
 public IThingGraph Use(Iori source, IThingGraph sink)
 {
     return(this.RawImport(source, sink, true));
 }
Esempio n. 29
0
        public IThingGraph RawImport(Iori source, IThingGraph sink, bool repair)
        {
            this.Log = new StringWriter();

            var links = new List <ILink>();

            if (repair)
            {
                var db4oGraph = sink as ThingGraph;
                if (db4oGraph != null)
                {
                    ReportClazzes(db4oGraph.Gateway as Gateway);
                }
            }

            var gateway = new Gateway();

            if (!repair)
            {
                gateway.Configuration.AllowVersionUpdates = true;
                gateway.Configuration.DetectSchemaChanges = true;
                //gateway.Configuration.RecoveryMode(true);
            }

            ConfigureAliases(gateway.Configuration);

            gateway.Open(source);
            var session = gateway.Session;

            ReportClazzes(gateway);
            SchemaFacade.InitSchemata();

            var cache = new Dictionary <IReflectClass, Tuple <IReflectClass, List <IReflectField>, Type> >();

            foreach (var item in session.Query <object>())
            {
                var thing = item as IThing;
                if (thing != null)
                {
                    ReportDetail(thing.Id.ToString());
                }
                var go = item as GenericObject;
                if (go != null)
                {
                    IReflectClass clazz = go.GetGenericClass();
                    Tuple <IReflectClass, List <IReflectField>, Type> defs = null;
                    if (!cache.TryGetValue(clazz, out defs))
                    {
                        var name = clazz.GetName();
                        name = name.Substring(0, name.LastIndexOf(','));

                        var newType = typeof(IThing).Assembly.GetType(name);

                        var fields = new List <IReflectField>();
                        var iClazz = clazz;
                        while (iClazz != null)
                        {
                            fields.AddRange(iClazz.GetDeclaredFields());
                            iClazz = iClazz.GetSuperclass();
                        }
                        defs = Tuple.Create(clazz, fields, newType);
                        cache.Add(clazz, defs);
                    }

                    var newThing = Activator.CreateInstance(defs.Item3, new object[] { null });

                    foreach (var field in defs.Item2)
                    {
                        var       val  = field.Get(go);
                        FieldInfo info = null;
                        var       type = defs.Item3;
                        while (info == null && type != null)
                        {
                            info = type.GetField(field.GetName(), BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.FlattenHierarchy);
                            if (info == null)
                            {
                                info = type.GetField(field.GetName(), BindingFlags.Instance | BindingFlags.Public | BindingFlags.FlattenHierarchy);
                            }
                            if (info == null && field.GetName() == "_writeDate")
                            {
                                info = type.GetField("_changeDate", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.FlattenHierarchy);
                            }
                            type = type.BaseType;
                        }
                        if (info != null && val != null && val.GetType() == info.FieldType)
                        {
                            info.SetValue(newThing, val);
                        }
                    }
                    ReportDetail(newThing.ToString());
                    if (repair)
                    {
                        var link = newThing as Link;
                        if (link != null)
                        {
                            link.GetByID = (id) => sink.GetById(id);
                            links.Add(newThing as ILink);
                        }
                        else if (newThing is IThing)
                        {
                            sink.Add(newThing as IThing);
                        }
                        else if (newThing is IIdContent <long> )
                        {
                            sink.ContentContainer.Add(newThing as IIdContent <long>);
                        }
                    }
                }
            }
            if (repair)
            {
                ReportDetail("write links...");

                foreach (var link in links)
                {
                    var idLink = link as ILink <Id>;
                    if (link.Marker == null && idLink.Marker != 0)
                    {
                        IThing marker = null;
                        if (Schema.IdentityMap.TryGetValue(idLink.Marker, out marker))
                        {
                            link.Marker = marker;
                        }
                    }
                    if (link.Marker == null)
                    {
                        link.Marker = CommonSchema.EmptyMarker;
                    }
                    if (link.Root != null && link.Leaf != null)
                    {
                        sink.Add(link);
                    }
                }
            }
            gateway.Close();
            ReportDetail("done:\t");
            if (this.Log != null)
            {
                var logfilename = source.ToFileName() + ".log";
                if (File.Exists(logfilename))
                {
                    File.Delete(logfilename);
                }
                var logfile = new StreamWriter(logfilename);
                logfile.Write(this.Log.ToString());
                logfile.Close();
            }
            return(sink);
        }
Esempio n. 30
0
 public IThingGraph Use(Iori source)
 {
     throw new ArgumentException("Repairer needs a Graph to store into");
 }