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


C# SparqlResultsFormat类代码示例

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


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

示例1: GetString

        public string GetString(SparqlResultsFormat format, IRdfWriter graphWriter = null)
        {
            switch (ResultType)
            {
                case BrightstarSparqlResultsType.VariableBindings:
                case BrightstarSparqlResultsType.Boolean:
                    var stringWriter = new System.IO.StringWriter();
                    var sparqlXmlWriter = GetSparqlWriter(format); 
                    sparqlXmlWriter.Save(_resultSet, stringWriter);
                    return stringWriter.GetStringBuilder().ToString();
                case BrightstarSparqlResultsType.Graph:
                    if (graphWriter == null)
                    {
#if WINDOWS_PHONE
                        // Cannot use DTD because the mobile version of XmlWriter doesn't support writing a DOCTYPE.
                        graphWriter = new RdfXmlWriter(WriterCompressionLevel.High, false);
#else
                        graphWriter = new RdfXmlWriter();
#endif
                    }
                    return StringWriter.Write(_graph, graphWriter);
                default:
                    throw new BrightstarInternalException(
                        String.Format("Unrecognized result type when serializing results string: {0}",
                                      ResultType));
            }
        }
开发者ID:GTuritto,项目名称:BrightstarDB,代码行数:27,代码来源:BrightstarSparqlResultSet.cs

示例2: SparqlResultModel

 public SparqlResultModel(string storeName, IBrightstarService service, SparqlRequestObject sparqlRequest, SparqlResultsFormat resultsFormat)
 {
     _storeName = storeName;
     _sparqlRequest = sparqlRequest;
     _service = service;
     ResultsFormat = resultsFormat;
 }
开发者ID:rharrisxtheta,项目名称:BrightstarDB,代码行数:7,代码来源:SparqlResultModel.cs

示例3: ExecuteSparqlQuery

 public static string ExecuteSparqlQuery(this IStore store, string sparqlExpression,
                                         SparqlResultsFormat resultsFormat)
 {
     var query = ParseSparql(sparqlExpression);
     var resultsStream = new MemoryStream();
     store.ExecuteSparqlQuery(query, resultsFormat.WithEncoding(new UTF8Encoding(false)), resultsStream);
     var ret = Encoding.UTF8.GetString(resultsStream.ToArray());
     return ret;
 }
开发者ID:GTuritto,项目名称:BrightstarDB,代码行数:9,代码来源:StoreExtensions.cs

示例4: Query

 public static string Query(this StoreWorker storeWorker, string sparqlExpression,
                            SparqlResultsFormat resultsFormat, string[] defaultGraphUris)
 {
     var query = ParseSparql(sparqlExpression);
     using (var resultsStream = new MemoryStream())
     {
         storeWorker.Query(query, resultsFormat.WithEncoding(new UTF8Encoding(false)), resultsStream, defaultGraphUris);
         return Encoding.UTF8.GetString(resultsStream.ToArray());
     }
 }
开发者ID:GTuritto,项目名称:BrightstarDB,代码行数:10,代码来源:StoreExtensions.cs

示例5: SparqlResultModel

 public SparqlResultModel(string storeName, ulong commitId, IBrightstarService service,
                          SparqlRequestObject sparqlRequest, SparqlResultsFormat resultsFormat, RdfFormat graphFormat)
 {
     _storeName = storeName;
     _commitId = commitId;
     _sparqlRequest = sparqlRequest;
     _service = service;
     ResultsFormat = resultsFormat;
     GraphFormat = graphFormat;
 }
开发者ID:GTuritto,项目名称:BrightstarDB,代码行数:10,代码来源:SparqlResultModel.cs

示例6: GetResultsStream

 public Stream GetResultsStream(SparqlResultsFormat format, RdfFormat graphFormat, DateTime? ifNotModifiedSince, out ISerializationFormat streamFormat)
 {
     if (_commitId > 0)
     {
         var commitPointInfo = _service.GetCommitPoint(_storeName, _commitId);
         if (commitPointInfo == null) throw new InvalidCommitPointException();
         return _service.ExecuteQuery(commitPointInfo, _sparqlRequest.Query, _sparqlRequest.DefaultGraphUri, format, graphFormat, out streamFormat);
     }
     return _service.ExecuteQuery(_storeName, _sparqlRequest.Query, _sparqlRequest.DefaultGraphUri, ifNotModifiedSince, format, graphFormat, out streamFormat);
 }
开发者ID:jaensen,项目名称:BrightstarDB,代码行数:10,代码来源:SparqlQueryProcessingModel.cs

示例7: GetSparqlWriter

 private ISparqlResultsWriter GetSparqlWriter(SparqlResultsFormat format)
 {
     var ext = format.DefaultExtension;
     if (ext.Equals(SparqlResultsFormat.Xml.DefaultExtension))
             return new SparqlXmlWriter();
     if (ext.Equals(SparqlResultsFormat.Json.DefaultExtension))
             return new SparqlJsonWriter();
     if (ext.Equals(SparqlResultsFormat.Tsv.DefaultExtension))
             return new SparqlTsvWriter();
     if (ext.Equals(SparqlResultsFormat.Csv.DefaultExtension))
         return new SparqlCsvWriter();
     throw new BrightstarInternalException("Unsupported SPARQL results format");
 }
开发者ID:GTuritto,项目名称:BrightstarDB,代码行数:13,代码来源:BrightstarSparqlResultSet.cs

示例8: GetWriter

 private static ISparqlResultsWriter GetWriter(SparqlResultsFormat format)
 {
     if (format == SparqlResultsFormat.Csv)
     {
         return new SparqlCsvWriter();
     }
     if (format == SparqlResultsFormat.Tsv)
     {
         return new SparqlTsvWriter();
     }
     if (format == SparqlResultsFormat.Json)
     {
         return new SparqlJsonWriter();
     }
     return new SparqlXmlWriter();
 }
开发者ID:jaensen,项目名称:BrightstarDB,代码行数:16,代码来源:GraphListModel.cs

示例9: SparqlQueryHandler

 public SparqlQueryHandler(ISerializationFormat targetFormat,
                           IEnumerable<string> defaultGraphUris)
 {
     if (targetFormat is SparqlResultsFormat)
     {
         _sparqlResultsFormat = targetFormat as SparqlResultsFormat;
     }
     if (targetFormat is RdfFormat)
     {
         _rdfFormat = targetFormat as RdfFormat;
     }
     if (defaultGraphUris != null)
     {
         _defaultGraphUris = defaultGraphUris.Select(g => new Uri(g)).ToList();
     }
 }
开发者ID:rexwhitten,项目名称:BrightstarDB,代码行数:16,代码来源:SparqlQueryHandler.cs

示例10: AsString

 public string AsString(SparqlResultsFormat format)
 {
     var g = new VDS.RDF.Graph();
     var results = new List<SparqlResult>();
     foreach (var graphUri in Graphs)
     {
         var s = new Set();
         s.Add(SparqlResultVariableName, g.CreateUriNode(new Uri(graphUri)));
         results.Add(new SparqlResult(s));
     }
     var rs = new SparqlResultSet(results);
     var writer = GetWriter(format);
     var sw = new StringWriter();
     writer.Save(rs, sw);
     sw.Flush();
     return sw.ToString();
 }
开发者ID:jaensen,项目名称:BrightstarDB,代码行数:17,代码来源:GraphListModel.cs

示例11: SparqlQueryResponse

 public SparqlQueryResponse(SparqlQueryProcessingModel model, DateTime? ifNotModifiedSince, SparqlResultsFormat format)
 {
     try
     {
         var resultStream = model.GetResultsStream(format, ifNotModifiedSince);
         Contents = resultStream.CopyTo;
         ContentType = format.MediaTypes[0];
         StatusCode = HttpStatusCode.OK;
     }
     catch (InvalidCommitPointException)
     {
         StatusCode = HttpStatusCode.NotFound;
     }
     catch (BrightstarStoreNotModifiedException)
     {
         StatusCode = HttpStatusCode.NotModified;
     }
 }
开发者ID:rharrisxtheta,项目名称:BrightstarDB,代码行数:18,代码来源:SparqlQueryResponse.cs

示例12: SparqlQueryResponse

 public SparqlQueryResponse(SparqlQueryProcessingModel model, DateTime? ifNotModifiedSince, SparqlResultsFormat format, RdfFormat graphFormat)
 {
     try
     {
         ISerializationFormat streamFormat;
         var resultStream = model.GetResultsStream(format, graphFormat, ifNotModifiedSince, out streamFormat);
         Contents = resultStream.CopyTo;
         ContentType = streamFormat.ToString();
         StatusCode = HttpStatusCode.OK;
     }
     catch (InvalidCommitPointException)
     {
         StatusCode = HttpStatusCode.NotFound;
     }
     catch (BrightstarStoreNotModifiedException)
     {
         StatusCode = HttpStatusCode.NotModified;
     }
 }
开发者ID:GTuritto,项目名称:BrightstarDB,代码行数:19,代码来源:SparqlQueryResponse.cs

示例13: MakeQueryCacheKey

 private static string MakeQueryCacheKey(string storeName, long commitTime, string query, IEnumerable<string> defaultGraphUris, SparqlResultsFormat format)
 {
     var graphHashCode = defaultGraphUris == null ? 0 : String.Join(",", defaultGraphUris).GetHashCode();
     return storeName + "_" + commitTime + "_" + query.GetHashCode() + "_" + graphHashCode + "." +
            format.DefaultExtension;
 }
开发者ID:rharrisxtheta,项目名称:BrightstarDB,代码行数:6,代码来源:ServerCore.cs

示例14: Query

 public string Query(string storeName, string queryExpression, IEnumerable<string> defaultGraphUris, SparqlResultsFormat resultsFormat)
 {
     var g = defaultGraphUris == null ? null : defaultGraphUris.ToArray();
     Logging.LogDebug("Query {0} {1}", storeName, queryExpression);
     var currentCommitPoint = _storeManager.GetMasterFile(Path.Combine(_baseLocation, storeName)).GetLatestCommitPoint();
     var cacheKey = MakeQueryCacheKey(storeName, currentCommitPoint.CommitTime.Ticks,
                                      queryExpression, g, resultsFormat);
     var cachedResult = GetCachedResult(cacheKey);
     if (cachedResult != null)
     {
         Logging.LogDebug("Returning cached result for query Query {0} {1}", storeName, queryExpression);
         return cachedResult;
     }
     var storeWorker = GetStoreWorker(storeName);
     var result =  storeWorker.Query(queryExpression, resultsFormat, g);
     //add to cache
     CacheResult(cacheKey, result);
     return result;
 }
开发者ID:rharrisxtheta,项目名称:BrightstarDB,代码行数:19,代码来源:ServerCore.cs

示例15: WriteResults

 private static void WriteResults(SparqlResultsFormat resultsFormat, Stream responseStream, string results)
 {
     StreamWriter streamWriter;
     if (resultsFormat.DefaultExtension.Equals(SparqlResultsFormat.Xml.DefaultExtension) &&
         !resultsFormat.Encoding.Equals(Encoding.Unicode))
     {
         // We need to rewrite the XML, otherwise the encoding setting is wrong
         XDocument resultsDoc = XDocument.Parse(results);
         streamWriter = new StreamWriter(responseStream, resultsFormat.Encoding);
         resultsDoc.Save(streamWriter);
         streamWriter.Flush();
     }
     else
     {
         streamWriter = new StreamWriter(responseStream, resultsFormat.Encoding);
         streamWriter.Write(results);
         streamWriter.Flush();
     }
 }
开发者ID:rharrisxtheta,项目名称:BrightstarDB,代码行数:19,代码来源:ServerCore.cs


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