本文整理汇总了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.");
}
}