• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# ITripleStore类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中ITripleStore的典型用法代码示例。如果您正苦于以下问题:C# ITripleStore类的具体用法?C# ITripleStore怎么用?C# ITripleStore使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ITripleStore类属于命名空间,在下文中一共展示了ITripleStore类的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: FolderStoreParserContext

 /// <summary>
 /// Creates a new Folder Store Parser Context
 /// </summary>
 /// <param name="store">Triple Store to parse into</param>
 /// <param name="folder">Folder</param>
 /// <param name="format">Format</param>
 /// <param name="threads">Threads to use</param>
 public FolderStoreParserContext(ITripleStore store, String folder, FolderStoreFormat format, int threads)
     : base(store)
 {
     this._folder = folder;
     this._format = format;
     this._threads = threads;
 }
开发者ID:jmahmud,项目名称:RDFer,代码行数:14,代码来源:FolderStoreParserContext.cs


示例2: Write

        /// <summary>
        /// Writes the given Triple Store to a String and returns the output in your chosen concrete RDF dataset syntax
        /// </summary>
        /// <param name="store">Triple Store</param>
        /// <param name="writer">Writer to use to generate conrete RDF Syntax</param>
        /// <returns></returns>
        public static String Write(ITripleStore store, IStoreWriter writer)
        {
            System.IO.StringWriter sw = new System.IO.StringWriter();
            writer.Save(store, new TextWriterParams(sw));

            return sw.ToString();
        }
开发者ID:almostEric,项目名称:DotNetRDF-4.0,代码行数:13,代码来源:StringWriter.cs


示例3: ThreadedSqlStoreWriterContext

 /// <summary>
 /// Creates a new Threaded SQL Store Writer Context
 /// </summary>
 /// <param name="store">Triple Store to save</param>
 /// <param name="manager">SQL IO Manager</param>
 /// <param name="threads">Number of threads to use</param>
 /// <param name="clearIfExists">Whether to clear graphs if they already exist</param>
 public ThreadedSqlStoreWriterContext(ITripleStore store, IThreadedSqlIOManager manager, int threads, bool clearIfExists)
 {
     this._store = store;
     this._manager = manager;
     this._writeThreads = threads;
     this._clearIfExists = clearIfExists;
 }
开发者ID:almostEric,项目名称:DotNetRDF-4.0,代码行数:14,代码来源:SqlStoreWriterContext.cs


示例4: BaseSparqlView

        /// <summary>
        /// Creates a new SPARQL View
        /// </summary>
        /// <param name="sparqlQuery">SPARQL Query</param>
        /// <param name="store">Triple Store to query</param>
        public BaseSparqlView(String sparqlQuery, ITripleStore store)
        {
            SparqlQueryParser parser = new SparqlQueryParser();
            this._q = parser.ParseFromString(sparqlQuery);
            this._store = store;

            this._async = new UpdateViewDelegate(this.UpdateViewInternal);
            this.Initialise();
        }
开发者ID:jbunzel,项目名称:MvcRQ_git,代码行数:14,代码来源:SparqlView.cs


示例5: Save

        /// <summary>
        /// Saves a Store in TriX format
        /// </summary>
        /// <param name="store">Store to save</param>
        /// <param name="parameters">Parameters indicating a Stream to write to</param>
        public void Save(ITripleStore store, IStoreParams parameters)
        {
            //Try and get the TextWriter to output to
            TextWriter output = null;
            if (parameters is StreamParams)
            {
                output = ((StreamParams)parameters).StreamWriter;
            } 
            else if (parameters is TextWriterParams)
            {
                output = ((TextWriterParams)parameters).TextWriter;
            }

            if (output != null)
            {
                try
                {
                    //Setup the XML document
                    XmlWriter writer = XmlWriter.Create(output, this.GetSettings());
                    writer.WriteStartDocument();
                    writer.WriteStartElement("TriX", TriXParser.TriXNamespaceURI);
                    writer.WriteStartAttribute("xmlns");
                    writer.WriteRaw(TriXParser.TriXNamespaceURI);
                    writer.WriteEndAttribute();

                    //Output Graphs as XML <graph> elements
                    foreach (IGraph g in store.Graphs) 
                    {
                        this.GraphToTriX(g, writer);
                    }

                    //Save the XML to disk
                    writer.WriteEndDocument();
                    writer.Close();
                    output.Close();
                }
                catch
                {
                    try
                    {
                        output.Close();
                    }
                    catch
                    {
                        //Just cleaning up
                    }
                    throw;
                }
            }
            else
            {
                throw new RdfStorageException("Parameters for the TriXWriter must be of the type StreamParams/TextWriterParams");
            }
        }
开发者ID:almostEric,项目名称:DotNetRDF-4.0,代码行数:59,代码来源:TriXWriter.cs


示例6: FindBlankNodeOwner

        private static IUriNode FindBlankNodeOwner(this IBlankNode blankNode, ITripleStore tripleStore)
        {
            INode current = blankNode;
            while ((current = tripleStore.Triples.Where(triple => triple.Object.Equals(current)).Select(triple => triple.Subject).FirstOrDefault()) != null)
            {
                if (current is IUriNode)
                {
                    return (IUriNode)current;
                }
            }

            return null;
        }
开发者ID:alien-mcl,项目名称:URSA,代码行数:13,代码来源:TripleStoreExtensions.cs


示例7: Save

        /// <summary>
        /// Saves the given Triple Store to the SQL Store that this class was instantiated with
        /// </summary>
        /// <param name="store">Store you wish to Save</param>
        /// <param name="parameters">Parameters for the Store</param>
        public virtual void Save(ITripleStore store, IStoreParams parameters)
        {
            if (parameters is ISQLIOParams)
            {
                SqlIOParams writeParams = (SqlIOParams)parameters;
                writeParams.Manager.PreserveState = true;
                SqlWriter writer = new SqlWriter(writeParams.Manager);

                foreach (IGraph g in store.Graphs)
                {
                    writer.Save(g, writeParams.ClearIfExists);
                }
            }
            else
            {
                throw new RdfStorageException("Parameters for the SQLStoreWriter must implement the interface ISQLIOParams");
            }
        }
开发者ID:jbunzel,项目名称:MvcRQ_git,代码行数:23,代码来源:SQLStoreWriter.cs


示例8: Save

        /// <summary>
        /// Saves the given Triple Store to an arbitrary store
        /// </summary>
        /// <param name="store">Store to Save</param>
        /// <param name="parameters">Parameters for the Store</param>
        /// <remarks>
        /// Parameters must be of type <see cref="GenericIOParams">GenericIOParams</see>
        /// </remarks>
        public void Save(ITripleStore store, IStoreParams parameters)
        {
            if (parameters is GenericIOParams)
            {
                //Create the Writer Context
                GenericStoreWriterContext context = new GenericStoreWriterContext(store, (GenericIOParams)parameters);

                //Queue Graphs for Writing
                foreach (IGraph g in store.Graphs)
                {
                    context.Add(g.BaseUri);
                }
                
                //Start making the async calls
                List<IAsyncResult> results = new List<IAsyncResult>();
                WriteGraphsDelegate d = new WriteGraphsDelegate(this.WriteGraphs);
                for (int i = 0; i < context.Threads; i++)
                {
                    results.Add(d.BeginInvoke(context, null, null));
                }

                //Wait for all the async calls to complete
                WaitHandle.WaitAll(results.Select(r => r.AsyncWaitHandle).ToArray());
                RdfThreadedOutputException outputEx = new RdfThreadedOutputException(WriterErrorMessages.ThreadedOutputFailure("TSV"));
                foreach (IAsyncResult result in results)
                {
                    try
                    {
                        d.EndInvoke(result);
                    }
                    catch (Exception ex)
                    {
                        outputEx.AddException(ex);
                    }
                }

                //If there were any errors we'll throw an RdfThreadedOutputException now
                if (outputEx.InnerExceptions.Any()) throw outputEx;
            }
            else
            {
                throw new RdfStorageException("Parameters for the GenericStoreWriter must be of type GenericIOParams");
            }
        }
开发者ID:almostEric,项目名称:DotNetRDF-4.0,代码行数:52,代码来源:GenericStoreWriter.cs


示例9: ParseDataset

        /// <summary>
        /// Parses a raw RDF Dataset String (attempts to auto-detect the format)
        /// </summary>
        /// <param name="store">Store to load into</param>
        /// <param name="data">Raw RDF Dataset String</param>
        /// <remarks>
        /// <p>
        /// Auto-detection is based on testing the string to see if it contains certain keyword constructs which might indicate a particular syntax has been used.  This detection may not always be accurate.
        /// </p>
        /// </remarks>
        public static void ParseDataset(ITripleStore store, String data)
        {
            if (store == null) throw new RdfParseException("Cannot read a RDF dataset into a null Graph");
            if (data == null) return;

            //Try to guess the format
            String format = "Unknown";
            try
            {
                if (data.Contains("<?xml") && data.Contains("<TriX"))
                {
                    //Probably TriX
                    format = "TriX";
                    ParseDataset(store, data, new TriXParser());
                }
                else if (data.Contains("@prefix") || data.Contains("@base"))
                {
                    //Probably TriG
                    format = "TriG";
                    ParseDataset(store, data, new TriGParser());
                }
                else
                {
                    //Take a stab at it being NQuads
                    //No real way to test as there's nothing particularly distinctive in NQuads
                    format = "NQuads";
                    ParseDataset(store, data, new NQuadsParser());
                }
            }
            catch (RdfParseException parseEx)
            {
                //Wrap the exception in an informational exception about what we guessed
                throw new RdfParseException("StringParser failed to parse the RDF Dataset string correctly, StringParser auto-detection guessed '" + format + "' but this failed to parse.  RDF Dataset string may be malformed or StringParser may have guessed incorrectly", parseEx);
            }
        }
开发者ID:jbunzel,项目名称:MvcRQ_git,代码行数:45,代码来源:StringParser.cs


示例10: Load

 /// <summary>
 /// Loads Graphs into the store using the settings the Reader was instantiated with
 /// </summary>
 /// <param name="store">Store to load into</param>
 /// <param name="parameters">Parameters indicating where to read from</param>
 public void Load(ITripleStore store, IStoreParams parameters)
 {
     if (store == null) throw new RdfParseException("Cannot read RDF from a Folder Store into a null Triple Store");
     this.Load(new StoreHandler(store), parameters);
 }
开发者ID:almostEric,项目名称:DotNetRDF-4.0,代码行数:10,代码来源:FolderStoreReader.cs


示例11: Save

        /// <summary>
        /// Saves a Store in NQuads format
        /// </summary>
        /// <param name="store">Store to save</param>
        /// <param name="parameters">Parameters indicating a Stream to write to</param>
        public void Save(ITripleStore store, IStoreParams parameters)
        {
            ThreadedStoreWriterContext context = null;
            if (parameters is StreamParams)
            {
                //Create a new Writer Context
            #if !SILVERLIGHT
                ((StreamParams)parameters).Encoding = Encoding.ASCII;
            #endif
                context = new ThreadedStoreWriterContext(store, ((StreamParams)parameters).StreamWriter, this._prettyPrint, false);
            }
            else if (parameters is TextWriterParams)
            {
                context = new ThreadedStoreWriterContext(store, ((TextWriterParams)parameters).TextWriter, this._prettyPrint, false);
            }

            if (context != null)
            {
                //Check there's something to do
                if (context.Store.Graphs.Count == 0)
                {
                    context.Output.Close();
                    return;
                }

                try
                {
                    if (this._multiThreaded)
                    {
                        //Queue the Graphs to be written
                        foreach (IGraph g in context.Store.Graphs)
                        {
                            if (g.BaseUri == null)
                            {
                                context.Add(UriFactory.Create(GraphCollection.DefaultGraphUri));
                            }
                            else
                            {
                                context.Add(g.BaseUri);
                            }
                        }

                        //Start making the async calls
                        List<IAsyncResult> results = new List<IAsyncResult>();
                        SaveGraphsDelegate d = new SaveGraphsDelegate(this.SaveGraphs);
                        for (int i = 0; i < this._threads; i++)
                        {
                            results.Add(d.BeginInvoke(context, null, null));
                        }

                        //Wait for all the async calls to complete
                        WaitHandle.WaitAll(results.Select(r => r.AsyncWaitHandle).ToArray());
                        RdfThreadedOutputException outputEx = new RdfThreadedOutputException(WriterErrorMessages.ThreadedOutputFailure("TSV"));
                        foreach (IAsyncResult result in results)
                        {
                            try
                            {
                                d.EndInvoke(result);
                            }
                            catch (Exception ex)
                            {
                                outputEx.AddException(ex);
                            }
                        }
                        context.Output.Close();

                        //If there were any errors we'll throw an RdfThreadedOutputException now
                        if (outputEx.InnerExceptions.Any()) throw outputEx;
                    }
                    else
                    {
                        foreach (IGraph g in context.Store.Graphs)
                        {
                            NTriplesWriterContext graphContext = new NTriplesWriterContext(g, context.Output);
                            foreach (Triple t in g.Triples)
                            {
                                context.Output.WriteLine(this.TripleToNQuads(graphContext, t));
                            }
                        }
                        context.Output.Close();
                    }
                }
                catch
                {
                    try
                    {
                        context.Output.Close();
                    }
                    catch
                    {
                        //Just cleaning up
                    }
                    throw;
                }
            }
//.........这里部分代码省略.........
开发者ID:jmahmud,项目名称:RDFer,代码行数:101,代码来源:NQuadsWriter.cs


示例12: FolderStoreWriterContext

 /// <summary>
 /// Creates a new Writer Context
 /// </summary>
 /// <param name="store">Triple Store</param>
 /// <param name="folder">Folder to write to</param>
 /// <param name="format">Folder Store Format</param>
 public FolderStoreWriterContext(ITripleStore store, String folder, FolderStoreFormat format)
     : this(store, folder)
 {
     this._format = format;
 }
开发者ID:almostEric,项目名称:DotNetRDF-4.0,代码行数:11,代码来源:FolderStoreWriterContext.cs


示例13: TripleStoreEventArgs

 /// <summary>
 /// Creates a new set of Triple Store Event Arguments
 /// </summary>
 /// <param name="store">Triple Store</param>
 /// <param name="g">Graph</param>
 public TripleStoreEventArgs(ITripleStore store, IGraph g)
     : this(store, new GraphEventArgs(g)) { }
开发者ID:jbunzel,项目名称:MvcRQ_git,代码行数:7,代码来源:Events.cs


示例14: Load

 /// <summary>
 /// Loads the contents of the given File into a Triple Store providing the RDF dataset format can be determined
 /// </summary>
 /// <param name="store">Triple Store to load into</param>
 /// <param name="filename">File to load from</param>
 /// <remarks>
 /// <para>
 /// The <see cref="FileLoader">FileLoader</see> attempts to select a Store Parser by examining the file extension to select the most likely MIME type for the file.  This assume that the file extension corresponds to one of the recognized file extensions for a RDF dataset format the library supports.  If this suceeds then a parser is chosen and used to parse the input file.
 /// </para>
 /// </remarks>
 public static void Load(ITripleStore store, String filename)
 {
     FileLoader.Load(store, filename, null);
 }
开发者ID:jmahmud,项目名称:RDFer,代码行数:14,代码来源:FileLoader.cs


示例15: Save

        /// <summary>
        /// Saves a Triple Store to CSV Format
        /// </summary>
        /// <param name="store">Triple Store to save</param>
        /// <param name="parameters">A set of <see cref="StreamParams">StreamParams</see></param>
        public void Save(ITripleStore store, IStoreParams parameters)
        {
            ThreadedStoreWriterContext context = null;
            if (parameters is StreamParams)
            {
                //Create a new Writer Context
                context = new ThreadedStoreWriterContext(store, ((StreamParams)parameters).StreamWriter);
            }
            else if (parameters is TextWriterParams)
            {
                context = new ThreadedStoreWriterContext(store, ((TextWriterParams)parameters).TextWriter);
            }

            if (context != null)
            {
                //Check there's something to do
                if (context.Store.Graphs.Count == 0)
                {
                    context.Output.Close();
                    return;
                }

                //Queue the Graphs to be written
                foreach (IGraph g in context.Store.Graphs)
                {
                    context.Add(g.BaseUri);
                }

                //Start making the async calls
                List<IAsyncResult> results = new List<IAsyncResult>();
                SaveGraphsDeletegate d = new SaveGraphsDeletegate(this.SaveGraphs);
                for (int i = 0; i < this._threads; i++)
                {
                    results.Add(d.BeginInvoke(context, null, null));
                }

                //Wait for all the async calls to complete
                WaitHandle.WaitAll(results.Select(r => r.AsyncWaitHandle).ToArray());
                RdfThreadedOutputException outputEx = new RdfThreadedOutputException(WriterErrorMessages.ThreadedOutputFailure("CSV"));
                foreach (IAsyncResult result in results)
                {
                    try
                    {
                        d.EndInvoke(result);
                    }
                    catch (Exception ex)
                    {
                        outputEx.AddException(ex);
                    }
                }
                context.Output.Close();

                //If there were any errors we'll throw an RdfThreadedOutputException now
                if (outputEx.InnerExceptions.Any()) throw outputEx;
            }
            else
            {
                throw new RdfStorageException("Parameters for the CsvStoreWriter must be of the type StreamParams/TextWriterParams");
            }
        }
开发者ID:jmahmud,项目名称:RDFer,代码行数:65,代码来源:CsvWriter.cs


示例16: Load

        /// <summary>
        /// Loads a RDF Dataset from the NQuads input into the given Triple Store
        /// </summary>
        /// <param name="store">Triple Store to load into</param>
        /// <param name="parameters">Parameters indicating the Stream to read from</param>
        public void Load(ITripleStore store, IStoreParams parameters)
        {
            if (store == null) throw new RdfParseException("Cannot read a RDF dataset into a null Store");

            this.Load(new StoreHandler(store), parameters);
        }
开发者ID:almostEric,项目名称:DotNetRDF-4.0,代码行数:11,代码来源:NQuadsParser.cs


示例17: Save

        /// <summary>
        /// Saves the given Store to Disk using the settings the Writer was instantiated with
        /// </summary>
        /// <param name="store">Store to save</param>
        /// <param name="parameters">Parameters indicating where to save to</param>
        public void Save(ITripleStore store, IStoreParams parameters)
        {
            if (parameters is FolderStoreParams)
            {
                //Get the Parameters
                FolderStoreWriterContext context = new FolderStoreWriterContext(store, (FolderStoreParams)parameters);

                //Create the Folder
                if (!Directory.Exists(context.Folder))
                {
                    Directory.CreateDirectory(context.Folder);
                }

                //Write list of Graphs and Queue URIs of Graphs for writing by the async calls
                StreamWriter graphlist = new StreamWriter(Path.Combine(context.Folder,"graphs.fstore"));
                String ext;
                switch (context.Format)
                {
                    case FolderStoreFormat.Turtle:
                        ext = ".ttl";
                        break;
                    case FolderStoreFormat.Notation3:
                        ext = ".n3";
                        break;
                    case FolderStoreFormat.RdfXml:
                        ext = ".rdf";
                        break;
                    default:
                        ext = ".ttl";
                        break;
                }
                graphlist.WriteLine(ext);
                foreach (Uri u in context.Store.Graphs.GraphUris)
                {
                    context.Add(u);
                    graphlist.WriteLine(u.GetSha256Hash() + ext);
                }
                graphlist.Close();

                //Start making the async calls
                List<IAsyncResult> results = new List<IAsyncResult>();
                SaveGraphsDelegate d = new SaveGraphsDelegate(this.SaveGraphs);
                for (int i = 0; i < context.Threads; i++)
                {
                    results.Add(d.BeginInvoke(context, null, null));
                }

                //Wait for all the async calls to complete
                WaitHandle.WaitAll(results.Select(r => r.AsyncWaitHandle).ToArray());
                RdfThreadedOutputException outputEx = new RdfThreadedOutputException(WriterErrorMessages.ThreadedOutputFailure("Folder Store"));
                foreach (IAsyncResult result in results)
                {
                    try
                    {
                        d.EndInvoke(result);
                    }
                    catch (Exception ex)
                    {
                        outputEx.AddException(ex);
                    }
                }

                //If there were any errors we'll throw an RdfThreadedOutputException now
                if (outputEx.InnerExceptions.Any()) throw outputEx;
            }
            else
            {
                throw new RdfStorageException("Parameters for the FolderStoreWriter must be of type FolderStoreParams");
            }
        }
开发者ID:almostEric,项目名称:DotNetRDF-4.0,代码行数:75,代码来源:FolderStoreWriter.cs


示例18: Save

        /// <summary>
        /// Saves a RDF Dataset as GZipped output
        /// </summary>
        /// <param name="store">Store to save</param>
        /// <param name="parameters">Storage Parameters</param>
        public void Save(ITripleStore store, IStoreParams parameters)
        {
            if (store == null) throw new RdfOutputException("Cannot output a new Triple Store");
            if (parameters == null) throw new RdfOutputException("Cannot output using null parameters");

            if (parameters is StreamParams)
            {
                StreamParams sp = (StreamParams)parameters;
                StreamWriter output = sp.StreamWriter;

                if (output.BaseStream is GZipStream)
                {
                    this._writer.Save(store, sp);
                }
                else
                {
                    this._writer.Save(store, new StreamParams(new GZipStream(output.BaseStream, CompressionMode.Compress)));
                }
            }
            else
            {
                throw new RdfOutputException("GZip Dataset Writers can only write to StreamParams instances");
            }
        }
开发者ID:jmahmud,项目名称:RDFer,代码行数:29,代码来源:BaseGZipDatasetWriter.cs


示例19: Load

 /// <summary>
 /// Loads a RDF Dataset from an Embedded Resource
 /// </summary>
 /// <param name="store">Store to load into</param>
 /// <param name="resource">Assembly Qualified Name of the Resource to load</param>
 /// <param name="parser">Parser to use (leave null for auto-selection)</param>
 public static void Load(ITripleStore store, String resource, IStoreReader parser)
 {
     if (store == null) throw new RdfParseException("Cannot read RDF Dataset into a null Store");
     EmbeddedResourceLoader.Load(new StoreHandler(store), resource, parser);
 }
开发者ID:jmahmud,项目名称:RDFer,代码行数:11,代码来源:EmbeddedResourceLoader.cs



注:本文中的ITripleStore类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# ITsString类代码示例发布时间:2022-05-24
下一篇:
C# ITrigger类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap