/// <summary> /// Applies Inference to the given Graph /// </summary> /// <param name="g">Graph to apply inference to</param> public void ApplyInference(IGraph g) { //Apply Inference if we have any Inference Engines defined if (this._reasoners.Count > 0) { //Set up Inference Graph if needed if (this._storeInferencesExternally) { if (!this._graphs.Contains(this._inferenceGraphUri)) { #if !NO_RWLOCK IGraph i = new ThreadSafeGraph(); #else IGraph i = new Graph(); #endif i.BaseUri = this._inferenceGraphUri; this._graphs.Add(i, true); } } //Apply inference foreach (IInferenceEngine reasoner in this._reasoners) { if (this._storeInferencesExternally) { reasoner.Apply(g, this._graphs[this._inferenceGraphUri]); } else { reasoner.Apply(g); } } } }
/// <summary> /// Applies Inference to the given Graph /// </summary> /// <param name="g">Graph to apply inference to</param> public void ApplyInference(IGraph g) { // Apply Inference if we have any Inference Engines defined if (_reasoners.Count > 0) { // Set up Inference Graph if needed if (_storeInferencesExternally) { if (!_graphs.Contains(_inferenceGraphUri)) { IGraph i = new ThreadSafeGraph(); i.BaseUri = _inferenceGraphUri; _graphs.Add(i, true); } } // Apply inference foreach (IInferenceEngine reasoner in _reasoners) { if (_storeInferencesExternally) { reasoner.Apply(g, _graphs[_inferenceGraphUri]); } else { reasoner.Apply(g); } } } }
internal static IGraph FindOrCreate(this ITripleStore tripleStore, Uri uri) { var graph = tripleStore.Graphs.FirstOrDefault(item => AbsoluteUriComparer.Default.Equals(item.BaseUri, uri)); if (graph != null) { return graph; } graph = new ThreadSafeGraph() { BaseUri = uri }; tripleStore.Add(graph); return graph; }