本文整理匯總了C#中SemWeb.Resource.ToString方法的典型用法代碼示例。如果您正苦於以下問題:C# Resource.ToString方法的具體用法?C# Resource.ToString怎麽用?C# Resource.ToString使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類SemWeb.Resource
的用法示例。
在下文中一共展示了Resource.ToString方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: Contains
/// <summary>
/// Returns whether the Store contains Statements which contain the given Resource
/// </summary>
/// <param name="resource">Resource</param>
/// <returns></returns>
public bool Contains(Resource resource)
{
//Implemented as a SPARQL ASK
String query = "ASK WHERE {{" + resource.ToString() + " ?p ?o} UNION {?s " + resource.ToString() + " ?o} UNION {?s ?p " + resource.ToString() + "}}";
return this.ContainsInternal(query);
}
示例2: FromSemWeb
/// <summary>
/// Helper method which converts a SemWeb resource into a PatternItem for use in a SPARQL Triple Pattern
/// </summary>
/// <param name="r">Resource</param>
/// <param name="mapping">Mapping of Variables & Blank Nodes to Pattern Items</param>
/// <param name="g">Graph</param>
/// <returns></returns>
private PatternItem FromSemWeb(Resource r, IGraph g, Dictionary<String, PatternItem> mapping)
{
if (r is Variable)
{
if (mapping.ContainsKey(r.ToString()))
{
return mapping[r.ToString()];
}
else
{
PatternItem temp = new VariablePattern(r.ToString());
mapping.Add(r.ToString(), temp);
return temp;
}
}
else if (r is BNode)
{
if (mapping.ContainsKey(r.ToString()))
{
return mapping[r.ToString()];
}
else
{
PatternItem temp = new BlankNodePattern(r.ToString().Substring(2));
mapping.Add(r.ToString(), temp);
return temp;
}
}
else
{
return new NodeMatchPattern(SemWebConverter.FromSemWeb(r, this.GetMapping(g)));
}
}
示例3: S
string S(Resource r, string v) {
if (r == null || r is Variable) {
return v;
} else if (r is Literal) {
return r.ToString();
} else if (r.Uri != null) {
if (r.Uri.IndexOf('>') != -1)
throw new ArgumentException("Invalid URI: " + r.Uri);
return "<" + r.Uri + ">";
} else {
throw new NotSupportedException("Blank node in select not supported.");
}
}