Xamarin 和 dotNetRdf
Xamarin and dotNetRdf
我正在尝试使用 dotNetRdf
通过 Xamarin 查询 DBpedia
这是我的代码:
SparqlRemoteEndpoint endpoint = new SparqlRemoteEndpoint(new Uri("http://dbpedia.org/sparql"), "http://dbpedia.org");
//Make a SELECT query against the Endpoint
SparqlResultSet results = endpoint.QueryWithResultSet("SELECT DISTINCT ?Concept WHERE {[] a ?Concept}");
foreach (SparqlResult result in results)
{
Console.WriteLine(result.ToString());
}
//Make a DESCRIBE query against the Endpoint
IGraph g = endpoint.QueryWithResultGraph("DESCRIBE ");
foreach (Triple t in g.Triples)
{
Console.WriteLine(t.ToString());
}
此代码在 C# 项目上运行良好,但在 Xamarin 中我在 QueryWithResultSet
上出现以下错误:
void SparqlRemoteEndpoint.QueryWithResultSet(string query, SparqlResultsCallback callback, object state)(+1 overload)
Makes a Query asynchronously where the expected Result is a SparqlResultSet i.e. SELECT and ASK Queries
我不明白我需要创建什么回调。
怎么了?
并非所有平台都支持同步 HTTP 操作,因此所有不支持此操作的平台都需要使用异步方法。
这是 .Net 平台的限制,他们选择不支持跨所有平台的同一组 API
我正在尝试使用 dotNetRdf
这是我的代码:
SparqlRemoteEndpoint endpoint = new SparqlRemoteEndpoint(new Uri("http://dbpedia.org/sparql"), "http://dbpedia.org");
//Make a SELECT query against the Endpoint
SparqlResultSet results = endpoint.QueryWithResultSet("SELECT DISTINCT ?Concept WHERE {[] a ?Concept}");
foreach (SparqlResult result in results)
{
Console.WriteLine(result.ToString());
}
//Make a DESCRIBE query against the Endpoint
IGraph g = endpoint.QueryWithResultGraph("DESCRIBE ");
foreach (Triple t in g.Triples)
{
Console.WriteLine(t.ToString());
}
此代码在 C# 项目上运行良好,但在 Xamarin 中我在 QueryWithResultSet
上出现以下错误:
void SparqlRemoteEndpoint.QueryWithResultSet(string query, SparqlResultsCallback callback, object state)(+1 overload)
Makes a Query asynchronously where the expected Result is a SparqlResultSet i.e. SELECT and ASK Queries
我不明白我需要创建什么回调。
怎么了?
并非所有平台都支持同步 HTTP 操作,因此所有不支持此操作的平台都需要使用异步方法。
这是 .Net 平台的限制,他们选择不支持跨所有平台的同一组 API