当前位置: 首页>>代码示例>>C#>>正文


C# IRdfHandler类代码示例

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


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

示例1: DescribeInternal

        /// <summary>
        /// Generates the Description for each of the Nodes to be described
        /// </summary>
        /// <param name="handler">RDF Handler</param>
        /// <param name="context">SPARQL Evaluation Context</param>
        /// <param name="nodes">Nodes to be described</param>
        protected override void DescribeInternal(IRdfHandler handler, SparqlEvaluationContext context, IEnumerable<INode> nodes)
        {
            //Rewrite Blank Node IDs for DESCRIBE Results
            Dictionary<String, INode> bnodeMapping = new Dictionary<string, INode>();

            //Get Triples for this Subject
            Queue<INode> bnodes = new Queue<INode>();
            HashSet<INode> expandedBNodes = new HashSet<INode>();
            INode rdfsLabel = handler.CreateUriNode(UriFactory.Create(NamespaceMapper.RDFS + "label"));
            foreach (INode n in nodes)
            {
                //Get Triples where the Node is the Subject
                foreach (Triple t in context.Data.GetTriplesWithSubject(n))
                {
                    if (t.Object.NodeType == NodeType.Blank)
                    {
                        if (!expandedBNodes.Contains(t.Object)) bnodes.Enqueue(t.Object);
                    }
                    if (!handler.HandleTriple((this.RewriteDescribeBNodes(t, bnodeMapping, handler)))) ParserHelper.Stop();
                }

                //Compute the Blank Node Closure for this Subject
                while (bnodes.Count > 0)
                {
                    INode bsubj = bnodes.Dequeue();
                    if (expandedBNodes.Contains(bsubj)) continue;
                    expandedBNodes.Add(bsubj);

                    foreach (Triple t2 in context.Data.GetTriplesWithSubjectPredicate(bsubj, rdfsLabel))
                    {
                        if (!handler.HandleTriple((this.RewriteDescribeBNodes(t2, bnodeMapping, handler)))) ParserHelper.Stop();
                    }
                }
            }
        }
开发者ID:jmahmud,项目名称:RDFer,代码行数:41,代码来源:LabelledDescription.cs

示例2: BaseParserContext

        /// <summary>
        /// Creates a new Base Parser Context
        /// </summary>
        /// <param name="handler">RDF Handler</param>
        /// <param name="traceParsing">Whether to trace parsing</param>
        public BaseParserContext(IRdfHandler handler, bool traceParsing)
        {
            if (handler == null) throw new ArgumentNullException("handler");
            this._handler = handler;
            this._traceParsing = traceParsing;

            this._baseUri = this._handler.GetBaseUri();
        }
开发者ID:almostEric,项目名称:DotNetRDF-4.0,代码行数:13,代码来源:BaseParserContext.cs

示例3: PagingHandler

 /// <summary>
 /// Creates a new Paging Handler
 /// </summary>
 /// <param name="handler">Inner Handler to use</param>
 /// <param name="limit">Limit</param>
 /// <param name="offset">Offset</param>
 /// <remarks>
 /// If you just want to use an offset and not apply a limit then set limit to be less than zero
 /// </remarks>
 public PagingHandler(IRdfHandler handler, int limit, int offset)
     : base(handler)
 {
     if (handler == null) throw new ArgumentNullException("handler");
     this._handler = handler;
     this._limit = Math.Max(-1, limit);
     this._offset = Math.Max(0, offset);
 }
开发者ID:almostEric,项目名称:DotNetRDF-4.0,代码行数:17,代码来源:PagingHandler.cs

示例4: ExecuteQuery

 /// <summary>
 /// Executes a SPARQL Query on the Graph handling the results with the given handlers
 /// </summary>
 /// <param name="rdfHandler">RDF Handler</param>
 /// <param name="resultsHandler">SPARQL Results Handler</param>
 /// <param name="sparqlQuery">SPARQL Query</param>
 public void ExecuteQuery(IRdfHandler rdfHandler, ISparqlResultsHandler resultsHandler, String sparqlQuery)
 {
     if (this._store == null)
     {
         this._store = new TripleStore();
         this._store.Add(this);
     }
     this._store.ExecuteQuery(rdfHandler, resultsHandler, sparqlQuery);
 }
开发者ID:jbunzel,项目名称:MvcRQ_git,代码行数:15,代码来源:QueryableGraph.cs

示例5: ImportUsingHandler

 protected override void ImportUsingHandler(IRdfHandler handler)
 {
     this.Information = "Importing from URI " + this._u.ToString();
     try
     {
         //Assume a RDF Graph
         UriLoader.Load(handler, this._u);
     }
     catch (RdfParserSelectionException)
     {
         //Assume a RDF Dataset
         UriLoader.LoadDataset(handler, this._u);
     }
 }
开发者ID:almostEric,项目名称:DotNetRDF-4.0,代码行数:14,代码来源:ImportTasks.cs

示例6: DescribeInternal

        /// <summary>
        /// Generates the Description for each of the Nodes to be described
        /// </summary>
        /// <param name="handler">RDF Handler</param>
        /// <param name="context">SPARQL Evaluation Context</param>
        /// <param name="nodes">Nodes to be described</param>
        protected override void DescribeInternal(IRdfHandler handler, SparqlEvaluationContext context, IEnumerable<INode> nodes)
        {
            //Rewrite Blank Node IDs for DESCRIBE Results
            Dictionary<String, INode> bnodeMapping = new Dictionary<string, INode>();

            //Get Triples for this Subject
            foreach (INode subj in nodes)
            {
                //Get Triples where the Node is the Subject
                foreach (Triple t in context.Data.GetTriplesWithSubject(subj))
                {
                    if (!handler.HandleTriple((this.RewriteDescribeBNodes(t, bnodeMapping, handler)))) ParserHelper.Stop();
                }
            }
        }
开发者ID:jmahmud,项目名称:RDFer,代码行数:21,代码来源:SimpleSubjectDescription.cs

示例7: ExecuteSparql

 public void ExecuteSparql(IRdfHandler rdfHandler, ISparqlResultsHandler resultsHandler, string sparqlQuery, IStore store)
 {
     try
     {
         var query = ParseSparql(sparqlQuery);
         var queryProcessor = new BrightstarQueryProcessor(store, new StoreSparqlDataset(store));
         queryProcessor.ProcessQuery(rdfHandler, resultsHandler, query);
     }
     catch (Exception ex)
     {
         Logging.LogError(BrightstarEventId.SparqlExecutionError,
                          "Error Executing Sparql {0}. Cause: {1}",
                          sparqlQuery, ex);
         throw;
     }
 }
开发者ID:Garwin4j,项目名称:BrightstarDB,代码行数:16,代码来源:SparqlQueryHandler.cs

示例8: DescribeInternal

        /// <summary>
        /// Generates the Description for each of the Nodes to be described
        /// </summary>
        /// <param name="handler">RDF Handler</param>
        /// <param name="context">SPARQL Evaluation Context</param>
        /// <param name="nodes">Nodes to be described</param>
        protected override void DescribeInternal(IRdfHandler handler, SparqlEvaluationContext context, IEnumerable<INode> nodes)
        {
            //Rewrite Blank Node IDs for DESCRIBE Results
            Dictionary<String, INode> bnodeMapping = new Dictionary<string, INode>();

            foreach (INode n in nodes)
            {
                if (n.NodeType == NodeType.Uri)
                {
                    IGraph g = context.Data[((IUriNode)n).Uri];
                    foreach (Triple t in g.Triples)
                    {
                        if (!handler.HandleTriple(this.RewriteDescribeBNodes(t, bnodeMapping, handler))) ParserHelper.Stop();
                    }
                }
            }
        }
开发者ID:jbunzel,项目名称:MvcRQ_git,代码行数:23,代码来源:NamedGraphDescription.cs

示例9: Load

        /// <inheritdoc />
        public void Load(IRdfHandler handler, TextReader input)
        {
            bool finished = false;
            try
            {
                handler.StartRdf();
                using (JsonReader jsonReader = new JsonTextReader(input))
                {
                    jsonReader.DateParseHandling = DateParseHandling.None;
                    JToken json = JsonLD.Core.JsonLdProcessor.Expand(JToken.Load(jsonReader));
                    foreach (JObject subjectJObject in json)
                    {
                        string subject = subjectJObject["@id"].ToString();
                        JToken type;
                        if (subjectJObject.TryGetValue("@type", out type))
                        {
                            HandleType(handler, subject, type);
                        }

                        foreach (var property in subjectJObject.Properties().Where(property => (property.Name != "@id") && (property.Name != "@type")))
                        {
                            HandleProperty(handler, subject, property);
                        }
                    }
                }

                finished = true;
                handler.EndRdf(true);
            }
            catch
            {
                finished = true;
                handler.EndRdf(false);
                throw;
            }
            finally
            {
                if (!finished)
                {
                    handler.EndRdf(true);
                }
            }
        }
开发者ID:alien-mcl,项目名称:URSA,代码行数:44,代码来源:JsonLdParser.cs

示例10: Load

        /// <summary>
        /// Loads a Graph from an Embedded Resource
        /// </summary>
        /// <param name="handler">RDF Handler to use</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(IRdfHandler handler, String resource, IRdfReader parser)
        {
            if (resource == null) throw new RdfParseException("Cannot read RDF from a null Resource");
            if (handler == null) throw new RdfParseException("Cannot read RDF using a null Handler");

            try
            {
                String resourceName = resource;

                if (resource.Contains(','))
                {
                    //Resource is an external assembly
                    String assemblyName = resource.Substring(resource.IndexOf(',') + 1).TrimStart();
                    resourceName = resourceName.Substring(0, resource.IndexOf(',')).TrimEnd();

                    //Try to load this assembly
                    Assembly asm = assemblyName.Equals(_currAsmName) ? Assembly.GetExecutingAssembly() : Assembly.Load(assemblyName);
                    if (asm != null)
                    {
                        //Resource is in the loaded assembly
                        EmbeddedResourceLoader.LoadGraphInternal(handler, asm, resourceName, parser);
                    }
                    else
                    {
                        throw new RdfParseException("The Embedded Resource '" + resourceName + "' cannot be loaded as the required assembly '" + assemblyName + "' could not be loaded");
                    }
                }
                else
                {
                    //Resource is in dotNetRDF
                    EmbeddedResourceLoader.LoadGraphInternal(handler, Assembly.GetExecutingAssembly(), resourceName, parser);
                }
            }
            catch (RdfParseException)
            {
                throw;
            }
            catch (Exception ex)
            {
                throw new RdfParseException("Unable to load the Embedded Resource '" + resource + "' as an unexpected error occurred", ex);
            }
        }
开发者ID:jmahmud,项目名称:RDFer,代码行数:48,代码来源:EmbeddedResourceLoader.cs

示例11: Describe

        /// <summary>
        /// Gets the Description Graph based on the Query Results from the given Evaluation Context passing the resulting Triples to the given RDF Handler
        /// </summary>
        /// <param name="handler">RDF Handler</param>
        /// <param name="context">SPARQL Evaluation Context</param>
        public void Describe(IRdfHandler handler, SparqlEvaluationContext context)
        {
            try
            {
                handler.StartRdf();

                //Apply Base URI and Namespaces to the Handler
                if (context.Query != null)
                {
                    if (context.Query.BaseUri != null)
                    {
                        if (!handler.HandleBaseUri(context.Query.BaseUri)) ParserHelper.Stop();
                    }
                    foreach (String prefix in context.Query.NamespaceMap.Prefixes)
                    {
                        if (!handler.HandleNamespace(prefix, context.Query.NamespaceMap.GetNamespaceUri(prefix))) ParserHelper.Stop();
                    }
                }

                //Get the Nodes needing describing
                List<INode> nodes = this.GetNodes(handler, context);
                if (nodes.Count > 0)
                {
                    //If there is at least 1 Node then start describing
                    this.DescribeInternal(handler, context, nodes);
                }

                handler.EndRdf(true);
            }
            catch (RdfParsingTerminatedException)
            {
                handler.EndRdf(true);
            }
            catch
            {
                handler.EndRdf(false);
                throw;
            }
        }
开发者ID:jbunzel,项目名称:MvcRQ_git,代码行数:44,代码来源:BaseDescribeAlgorithm.cs

示例12: Load

        /// <summary>
        /// Loads a RDF Dataset from the NQuads input using a RDF Handler
        /// </summary>
        /// <param name="handler">RDF Handler to use</param>
        /// <param name="parameters">Parameters indicating the Stream to read from</param>
        public void Load(IRdfHandler handler, IStoreParams parameters)
        {
            if (handler == null) throw new ArgumentNullException("handler", "Cannot parse an RDF Dataset using a null RDF Handler");
            if (parameters == null) throw new ArgumentNullException("parameters", "Cannot parse an RDF Dataset using null Parameters");

            //Try and get the Input from the parameters
            TextReader input = null;
            if (parameters is StreamParams)
            {
                //Get Input Stream
                input = ((StreamParams)parameters).StreamReader;

#if !SILVERLIGHT
                //Issue a Warning if the Encoding of the Stream is not ASCII
                if (!((StreamReader)input).CurrentEncoding.Equals(Encoding.ASCII))
                {
                    this.RaiseWarning("Expected Input Stream to be encoded as ASCII but got a Stream encoded as " + ((StreamReader)input).CurrentEncoding.EncodingName + " - Please be aware that parsing errors may occur as a result");
                }
#endif
            } 
            else if (parameters is TextReaderParams)
            {
                input = ((TextReaderParams)parameters).TextReader;
            }

            if (input != null)
            {
                try
                {
                    //Setup Token Queue and Tokeniser
                    NTriplesTokeniser tokeniser = new NTriplesTokeniser(input);
                    tokeniser.NQuadsMode = true;
                    TokenQueue tokens = new TokenQueue();
                    tokens.Tokeniser = tokeniser;
                    tokens.Tracing = this._tracetokeniser;
                    tokens.InitialiseBuffer();

                    //Invoke the Parser
                    this.Parse(handler, tokens);
                }
                catch
                {
                    throw;
                }
                finally
                {
                    try
                    {
                        input.Close();
                    }
                    catch
                    {
                        //No catch actions - just cleaning up
                    }
                }
            }
            else
            {
                throw new RdfStorageException("Parameters for the NQuadsParser must be of the type StreamParams/TextReaderParams");
            }
        }
开发者ID:almostEric,项目名称:DotNetRDF-4.0,代码行数:66,代码来源:NQuadsParser.cs

示例13: ProcessQuery

 /// <summary>
 /// Processes a SPARQL Query asynchronously passing the results to the relevant handler and invoking the callback when the query completes
 /// </summary>
 /// <param name="rdfHandler">RDF Handler</param>
 /// <param name="resultsHandler">Results Handler</param>
 /// <param name="query">SPARQL Query</param>
 /// <param name="callback">Callback</param>
 /// <param name="state">State to pass to the callback</param>
 public void ProcessQuery(IRdfHandler rdfHandler, ISparqlResultsHandler resultsHandler, SparqlQuery query, QueryCallback callback, Object state)
 {
     query.QueryExecutionTime = null;
     DateTime start = DateTime.Now;
     try
     {
         this._svc.Query(rdfHandler, resultsHandler, query.ToString(), callback, state);
     }
     finally
     {
         TimeSpan elapsed = (DateTime.Now - start);
         query.QueryExecutionTime = (DateTime.Now - start);
     }
 }
开发者ID:jmahmud,项目名称:RDFer,代码行数:22,代码来源:PelletQueryProcessor.cs

示例14: RdfAParserContext

 /// <summary>
 /// Creates a new Parser Context
 /// </summary>
 /// <param name="handler">RDF Handler to use</param>
 /// <param name="document">HTML Document</param>
 public RdfAParserContext(IRdfHandler handler, HtmlDocument document)
     : this(handler, document, false) { }
开发者ID:almostEric,项目名称:DotNetRDF-4.0,代码行数:7,代码来源:RdfAParserContext.cs

示例15: Load

        /// <summary>
        /// Read RDF/JSON Syntax from some Stream using a RDF Handler
        /// </summary>
        /// <param name="handler">RDF Handler to use</param>
        /// <param name="input">Stream to read from</param>
        public void Load(IRdfHandler handler, StreamReader input)
        {
            if (handler == null) throw new RdfParseException("Cannot read RDF into a null RDF Handler");
            if (input == null) throw new RdfParseException("Cannot read RDF from a null Stream");

            //Issue a Warning if the Encoding of the Stream is not UTF-8
            if (!input.CurrentEncoding.Equals(Encoding.UTF8))
            {
#if !SILVERLIGHT
                this.RaiseWarning("Expected Input Stream to be encoded as UTF-8 but got a Stream encoded as " + input.CurrentEncoding.EncodingName + " - Please be aware that parsing errors may occur as a result");
#else
                this.RaiseWarning("Expected Input Stream to be encoded as UTF-8 but got a Stream encoded as " + input.CurrentEncoding.GetType().Name + " - Please be aware that parsing errors may occur as a result");
#endif
            }

            this.Load(handler, (TextReader)input);
        }
开发者ID:jbunzel,项目名称:MvcRQ_git,代码行数:22,代码来源:RDFJSONParser.cs


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