本文整理汇总了C#中ILiteralNode类的典型用法代码示例。如果您正苦于以下问题:C# ILiteralNode类的具体用法?C# ILiteralNode怎么用?C# ILiteralNode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ILiteralNode类属于命名空间,在下文中一共展示了ILiteralNode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ValueInternal
/// <summary>
/// Gets the Value of the function as applied to the given String Literal and Argument
/// </summary>
/// <param name="stringLit">Simple/String typed Literal</param>
/// <param name="arg">Argument</param>
/// <returns></returns>
public override IValuedNode ValueInternal(ILiteralNode stringLit, ILiteralNode arg)
{
if (stringLit.Value.Equals(string.Empty))
{
if (arg.Value.Equals(string.Empty))
{
//The Empty String starts with the Empty String
return new BooleanNode(null, true);
}
else
{
//Empty String doesn't start with a non-empty string
return new BooleanNode(null, false);
}
}
else if (arg.Value.Equals(string.Empty))
{
//Any non-empty string starts with the empty string
return new BooleanNode(null, true);
}
else
{
//Otherwise evalute the StartsWith
return new BooleanNode(null, stringLit.Value.StartsWith(arg.Value));
}
}
示例2: ValueInternal
/// <summary>
/// Gets the Value of the function as applied to the given String Literal
/// </summary>
/// <param name="stringLit">Simple/String typed Literal</param>
/// <returns></returns>
protected override IValuedNode ValueInternal(ILiteralNode stringLit)
{
string temp = stringLit.Value.Trim();
Regex normalizeSpace = new Regex("\\s{2,}");
temp = normalizeSpace.Replace(temp, " ");
return new StringNode(null, temp, UriFactory.Create(XmlSpecsHelper.XmlSchemaDataTypeString));
}
示例3: ValueInternal
/// <summary>
/// Converts the given String Literal to upper case
/// </summary>
/// <param name="stringLit">String Literal</param>
/// <returns></returns>
protected override IValuedNode ValueInternal(ILiteralNode stringLit)
{
if (stringLit.DataType != null)
{
return new StringNode(null, stringLit.Value.ToUpper(), stringLit.DataType);
}
else
{
return new StringNode(null, stringLit.Value.ToUpper(), stringLit.Language);
}
}
示例4: FormatLiteralNode
/// <summary>
/// Formats Literals for CSV output
/// </summary>
/// <param name="l">Literal</param>
/// <param name="segment">Triple Segment</param>
/// <returns></returns>
protected override string FormatLiteralNode(ILiteralNode l, TripleSegment? segment)
{
String value = l.Value;
if (value.Contains('"') || value.Contains(',') || value.Contains('\n') || value.Contains('\r'))
{
return '"' + value.Replace("\"", "\"\"") + '"';
}
else
{
return value;
}
}
示例5: LiteralNodeControl
public LiteralNodeControl(ILiteralNode n, INodeFormatter formatter)
{
InitializeComponent();
String data = formatter.Format(n);
if (data.Contains("\"^^"))
{
String value = data.Substring(0, data.IndexOf("\"^^") + 3);
String dt = data.Substring(data.IndexOf("\"^^") + 4);
this.txtValue.Content = value;
this.lnkDatatypeUri.Text = dt;
this._u = n.DataType;
}
else
{
this.txtValue.Content = data;
}
}
示例6: ValueInternal
/// <summary>
/// Gets the Value of the function as applied to the given String Literal and Argument
/// </summary>
/// <param name="stringLit">Simple/String typed Literal</param>
/// <param name="arg">Argument</param>
/// <returns></returns>
public override IValuedNode ValueInternal(ILiteralNode stringLit, ILiteralNode arg)
{
if (stringLit.Value.Equals(string.Empty))
{
//Empty string cannot contain anything
return new BooleanNode(null, false);
}
else if (arg.Value.Equals(string.Empty))
{
//Any non-empty string contains the empty string
return new BooleanNode(null, true);
}
else
{
//Evalute the Contains
return new BooleanNode(null, stringLit.Value.Contains(arg.Value));
}
}
示例7: ValueInternal
/// <summary>
/// Gets the Value of the function as applied to the given String Literal and Argument
/// </summary>
/// <param name="stringLit">Simple/String typed Literal</param>
/// <param name="arg">Argument</param>
/// <returns></returns>
public override IValuedNode ValueInternal(ILiteralNode stringLit, ILiteralNode arg)
{
if (arg.Value.Equals(string.Empty))
{
//The substring after the empty string is the input string
return new StringNode(null, stringLit.Value, UriFactory.Create(XmlSpecsHelper.XmlSchemaDataTypeString));
}
else
{
//Does the String contain the search string?
if (stringLit.Value.Contains(arg.Value))
{
string result = stringLit.Value.Substring(stringLit.Value.IndexOf(arg.Value) + arg.Value.Length);
return new StringNode(null, result, UriFactory.Create(XmlSpecsHelper.XmlSchemaDataTypeString));
}
else
{
//If it doesn't contain the search string the empty string is returned
return new StringNode(null, string.Empty, UriFactory.Create(XmlSpecsHelper.XmlSchemaDataTypeString));
}
}
}
示例8: ToTimeSpan
/// <summary>
/// Converts a Literal Node to a Time Span
/// </summary>
/// <param name="n">Literal Node</param>
/// <returns></returns>
public static TimeSpan ToTimeSpan(ILiteralNode n)
{
if (n.DataType == null) throw new RdfQueryException("Cannot convert an untyped Literal to a Time Span");
return TimeSpan.Parse(n.Value);
}
示例9: ValueInternal
/// <summary>
/// Determines whether the String contains the given Argument
/// </summary>
/// <param name="stringLit">String Literal</param>
/// <param name="argLit">Argument Literal</param>
/// <returns></returns>
protected override bool ValueInternal(ILiteralNode stringLit, ILiteralNode argLit)
{
return stringLit.Value.Contains(argLit.Value);
}
示例10: ToInteger
/// <summary>
/// Converts a Literal Node to an Integer
/// </summary>
/// <param name="n">Literal Node</param>
/// <returns></returns>
public static Int64 ToInteger(ILiteralNode n)
{
if (n.DataType == null) throw new RdfQueryException("Cannot convert an untyped Literal to an Integer");
return Int64.Parse(n.Value);
}
示例11: ToDateTimeOffset
/// <summary>
/// Converts a Literal Node to a Date Time Offset
/// </summary>
/// <param name="n">Literal Node</param>
/// <returns></returns>
public static DateTimeOffset ToDateTimeOffset(ILiteralNode n)
{
if (n.DataType == null) throw new RdfQueryException("Cannot convert an untyped Literal to a Date Time");
return DateTimeOffset.Parse(n.Value, null, System.Globalization.DateTimeStyles.AssumeUniversal);
}
示例12: ValueInternal
/// <summary>
/// Gets the Value of the function as applied to the given String Literal and Argument
/// </summary>
/// <param name = "stringLit">Simple/String typed Literal</param>
/// <param name = "arg">Argument</param>
/// <returns></returns>
public override INode ValueInternal(ILiteralNode stringLit, ILiteralNode arg)
{
if (arg.Value.Equals(String.Empty))
{
//The substring before the empty string is the empty string
return new LiteralNode(null, String.Empty, new Uri(XmlSpecsHelper.XmlSchemaDataTypeString));
}
else
{
//Does the String contain the search string?
if (stringLit.Value.Contains(arg.Value))
{
String result = stringLit.Value.Substring(0, stringLit.Value.IndexOf(arg.Value));
return new LiteralNode(null, result, new Uri(XmlSpecsHelper.XmlSchemaDataTypeString));
}
else
{
//If it doesn't contain the search string the empty string is returned
return new LiteralNode(null, String.Empty, new Uri(XmlSpecsHelper.XmlSchemaDataTypeString));
}
}
}
示例13: ValueInternal
/// <summary>
/// Gets the Value of the function as applied to the given String Literal
/// </summary>
/// <param name = "stringLit">Simple/String typed Literal</param>
/// <returns></returns>
protected override INode ValueInternal(ILiteralNode stringLit)
{
return new LiteralNode(null, Uri.EscapeUriString(stringLit.Value));
}
示例14: FormatLiteralNode
/// <summary>
/// Formats a Literal Node using QName compression for the datatype if possible
/// </summary>
/// <param name="l">Literal Node</param>
/// <param name="segment">Triple Segment</param>
/// <returns></returns>
protected abstract override string FormatLiteralNode(ILiteralNode l, TripleSegment? segment);
示例15: MakeLiteralObject
static JObject MakeLiteralObject(ILiteralNode node)
{
if (node.DataType == null)
{
return new JObject { { "@value", node.Value } };
}
else
{
string dataType = node.DataType.ToString();
switch (dataType)
{
case "http://www.w3.org/2001/XMLSchema#integer":
return new JObject { { "@value", int.Parse(node.Value) } };
case "http://www.w3.org/2001/XMLSchema#boolean":
return new JObject { { "@value", bool.Parse(node.Value) } };
case "http://www.w3.org/2001/XMLSchema#decimal":
return new JObject { { "@value", decimal.Parse(node.Value) } };
case "http://www.w3.org/2001/XMLSchema#long":
return new JObject { { "@value", long.Parse(node.Value) } };
case "http://www.w3.org/2001/XMLSchema#short":
return new JObject { { "@value", short.Parse(node.Value) } };
case "http://www.w3.org/2001/XMLSchema#float":
return new JObject { { "@value", float.Parse(node.Value) } };
case "http://www.w3.org/2001/XMLSchema#double":
return new JObject { { "@value", double.Parse(node.Value) } };
default:
return new JObject
{
{ "@value", node.Value },
{ "@type", dataType }
};
}
}
}