private Task DelayedDataRead(FileInfo srcFile, IRdfData rdf, int id) { return(new Task(() => { var g = rdf.GetSelfGraph(rdf.BlankSelf($"g{id}")); using var rd = srcFile.OpenText(); NTripleFile.Read(g, rd).Wait(); }, TaskCreationOptions.LongRunning)); }
/// <summary> /// Initialize the <see cref="AppData"/> singleton. /// </summary> /// <exception cref="FactoryAlreadyInitialized"></exception> public static IRdfData Init(IRdfData data) { if (_instance != null && _instance != data) { throw new FactoryAlreadyInitialized(); } _instance = data; return(_instance); }
public RdfDataFetcher(IRdfData rdf) { _rdf = rdf; BackingFile = _rdf.Uri("sys:/backingFile"); if (!_rdf.Stats().Mappings.Any(x => x is FileInfoNodeMap)) { throw new Exception( $"Must include node map {nameof(FileInfoNodeMap)}"); } }
private void LoadSettings(IRdfData rdf) { var baseSettings = rdf.GetBlankGraph("baseSettings"); new NTripleFile(Files.TestData.Settings) .Read(baseSettings).Wait(); var debugSettings = rdf.GetBlankGraph("debugSettings"); new NTripleFile(Files.TestData.SettingsDebug) .Read(debugSettings).Wait(); }
/// <summary>Create graph with Id and data from other graphs</summary> public Graph(IRdfData rdf, Node <UriOrBlank> id, IEnumerable <Node <UriOrBlank> > other) { _rdf = rdf; Id = id; Other = other.Distinct() .Where(x => x != id) .ToArray(); _includedQuads = rdf.GraphData(Other); }
private Node <UriOrBlank> LoadSampleData(IRdfData data, Node <UriOrBlank> g) { var me = data.Uri("x:me"); var link = data.Uri("a:linkTo"); var name = data.Uri("a:name"); data.Update.From(g) .For(me) .With(link) .Add(data.Uri("http://my.blog")) .Then() .With(name).Add(data.New("My Name")); return(g); }
public void CreateRdfStore() { //create default thread-locked version. IRdfData rdf = RdfDataFactory.CreateDefault(); Assert.IsTrue(rdf is RdfDataThreadLock); //create basic version. rdf = RdfDataFactory.CreateNoLock(); Assert.IsTrue(rdf is RdfData); //setup app singleton RdfDataFactory.Init(RdfDataFactory.CreateNoLock()); //use singleton rdf = RdfDataFactory.AppData; Assert.IsNotNull(rdf); }
/// <summary>Get new blank graph; has all the current data</summary> public static Graph GetBlankGraph(this IRdfData store, string?id = null) => store.GetGraph(store.BlankSelf(id), store.GraphIds);
/// <summary> /// Create new RDF builder for fluent updates. /// </summary> public RdfBuilder(IRdfData data) { _owner = data; }
/// <summary>Assert / add a quad.</summary> public static IRdfData Assert(this IRdfData rdf, Node <UriOrBlank> graph, Node <UriOrBlank> sub, UriNode predicate, Node val) => rdf.Assert(graph, sub, predicate, val, out _);
/// <summary>Retract a set of quads</summary> /// <returns>The number of quads actually removed</returns> public static int Retract(this IRdfData self, IEnumerable <Quad> quads) => self.Retract(quads.ToArray());
/// <summary>Get default graph with all data</summary> public static Graph GetDefault(this IRdfData store) => store.GetGraph(store.Default, store.GraphIds);
/// <summary>Get system graph with all data</summary> public static Graph GetSystem(this IRdfData store) => store.GetGraph(store.System, store.GraphIds);
/// <summary> /// A set of quads ordered by graph. /// Includes data from the specified additional graph(s) /// </summary> public static Graph GetGraph(this IRdfData store, Node <UriOrBlank> graphId, IEnumerable <Node <UriOrBlank> > other) => store.GetGraph(graphId, other.ToArray());
/// <summary>Get self graph: graph contains only its own quads</summary> public static Graph GetSelfGraph(this IRdfData rdf, string graphUri) => rdf.GetGraph(rdf.Uri(graphUri), Enumerable.Empty <Node <UriOrBlank> >());
/// <summary>Get self graph: graph contains only its own quads</summary> public static Graph GetSelfGraph(this IRdfData store, Node <UriOrBlank> graphId) => store.GetGraph(graphId, Enumerable.Empty <Node <UriOrBlank> >());
/// <summary>Get full graph: graph contains all current quads.</summary> public static Graph GetFullGraph(this IRdfData store, Node <UriOrBlank> graphUri) => store.GetGraph(graphUri, store.GraphIds);
/// <summary>Get full graph: graph contains all current quads.</summary> public static Graph GetFullGraph(this IRdfData rdf, string graphUri) => rdf.GetGraph(rdf.Uri(graphUri), rdf.GraphIds);