本文整理汇总了C#中ILiteralNode类的典型用法代码示例。如果您正苦于以下问题:C# ILiteralNode类的具体用法?C# ILiteralNode怎么用?C# ILiteralNode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ILiteralNode类属于命名空间,在下文中一共展示了ILiteralNode类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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));
}
}
开发者ID:jmahmud,项目名称:RDFer,代码行数:32,代码来源:StartsWithFunction.cs
示例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));
}
开发者ID:jmahmud,项目名称:RDFer,代码行数:13,代码来源:NormalizeSpaceFunction.cs
示例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);
}
}
开发者ID:jmahmud,项目名称:RDFer,代码行数:16,代码来源:UCaseFunction.cs
示例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;
}
}
开发者ID:jbunzel,项目名称:MvcRQ_git,代码行数:18,代码来源:CsvFormatter.cs
示例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;
}
}
开发者ID:almostEric,项目名称:DotNetRDF-4.0,代码行数:18,代码来源:LiteralNodeControl.xaml.cs
示例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));
}
}
开发者ID:jmahmud,项目名称:RDFer,代码行数:24,代码来源:ContainsFunction.cs
示例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));
}
}
}
开发者ID:jmahmud,项目名称:RDFer,代码行数:28,代码来源:SubstringAfterFunction.cs
示例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);
}
开发者ID:jbunzel,项目名称:MvcRQ_git,代码行数:10,代码来源:SPARQLSpecsHelper.cs
示例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);
}
开发者ID:jmahmud,项目名称:RDFer,代码行数:10,代码来源:ContainsFunction.cs
示例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);
}
开发者ID:jbunzel,项目名称:MvcRQ_git,代码行数:10,代码来源:SPARQLSpecsHelper.cs
示例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);
}
开发者ID:jbunzel,项目名称:MvcRQ_git,代码行数:10,代码来源:SPARQLSpecsHelper.cs
示例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));
}
}
}
开发者ID:almostEric,项目名称:DotNetRDF-4.0,代码行数:28,代码来源:XPathStringFunctions.cs
示例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));
}
开发者ID:almostEric,项目名称:DotNetRDF-4.0,代码行数:9,代码来源:SparqlStringFunctions.cs
示例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);
开发者ID:almostEric,项目名称:DotNetRDF-4.0,代码行数:7,代码来源:QNameFormatter.cs
示例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 }
};
}
}
}
开发者ID:NuGet,项目名称:NuGet.Services.Metadata,代码行数:42,代码来源:JsonLdWriter.cs
示例16: FormatLiteralNode
/// <summary>
/// Formats a Literal Node
/// </summary>
/// <param name="l">Literal Node</param>
/// <param name="segment">Triple Segment</param>
/// <returns></returns>
protected override string FormatLiteralNode(ILiteralNode l, TripleSegment? segment)
{
StringBuilder output = new StringBuilder();
String value;
output.Append('"');
value = l.Value;
if (!value.IsFullyEscaped(this._validEscapes, this._litEscapes))
{
//This first replace escapes all back slashes for good measure
value = value.EscapeBackslashes(this._validEscapes);
//Then these escape characters that can't occur in a NTriples literal
value = value.Replace("\n", "\\n");
value = value.Replace("\r", "\\r");
value = value.Replace("\t", "\\t");
value = value.Escape('"');
//Then remove null character since it doesn't change the meaning of the Literal
value = value.Replace("\0", "");
}
foreach (char c in value.ToCharArray())
{
output.Append(this.FormatChar(c));
}
output.Append('"');
if (!l.Language.Equals(String.Empty))
{
output.Append('@');
output.Append(l.Language.ToLower());
}
else if (l.DataType != null)
{
output.Append("^^<");
foreach (char c in this.FormatUri(l.DataType))
{
output.Append(this.FormatChar(c));
}
output.Append('>');
}
return output.ToString();
}
开发者ID:jbunzel,项目名称:MvcRQ_git,代码行数:52,代码来源:NTriplesFormatter.cs
示例17: CompareLiterals
/// <summary>
/// Compares two Literal Nodes
/// </summary>
/// <param name="a">First Literal Node</param>
/// <param name="b">Second Literal Node</param>
/// <returns></returns>
public static int CompareLiterals(ILiteralNode a, ILiteralNode b)
{
if (ReferenceEquals(a, b)) return 0;
if (a == null)
{
if (b == null) return 0;
return -1;
}
else if (b == null)
{
return 1;
}
//Literal Nodes are ordered based on Type and lexical form
if (a.DataType == null && b.DataType != null)
{
//Untyped Literals are less than Typed Literals
//Return a -1 to indicate this
return -1;
}
else if (a.DataType != null && b.DataType == null)
{
//Typed Literals are greater than Untyped Literals
//Return a 1 to indicate this
return 1;
}
else if (a.DataType == null && b.DataType == null)
{
//If neither are typed use Lexical Ordering on the value
return a.Value.CompareTo(b.Value);
}
else if (EqualityHelper.AreUrisEqual(a.DataType, b.DataType))
{
//Are we using a known and orderable DataType?
String type = a.DataType.ToString();
if (!XmlSpecsHelper.IsSupportedType(type))
{
//Don't know how to order so use lexical order on the value
return a.Value.CompareTo(b.Value);
}
else
{
try
{
switch (type)
{
case XmlSpecsHelper.XmlSchemaDataTypeBoolean:
//Can use Lexical ordering for this
return a.Value.ToLower().CompareTo(b.Value.ToLower());
case XmlSpecsHelper.XmlSchemaDataTypeByte:
//Remember that xsd:byte is actually equivalent to SByte in .Net
//Extract the Byte Values and compare
sbyte aSByte, bSByte;
if (SByte.TryParse(a.Value, out aSByte))
{
if (SByte.TryParse(b.Value, out bSByte))
{
return aSByte.CompareTo(bSByte);
}
else
{
return -1;
}
}
else
{
if (SByte.TryParse(b.Value, out bSByte))
{
return 1;
}
else
{
return a.Value.CompareTo(b.Value);
}
}
case XmlSpecsHelper.XmlSchemaDataTypeUnsignedByte:
//Remember that xsd:unsignedByte is equivalent to Byte in .Net
//Extract the Byte Values and compare
byte aByte, bByte;
if (Byte.TryParse(a.Value, out aByte))
{
if (Byte.TryParse(b.Value, out bByte))
{
return aByte.CompareTo(bByte);
}
else
{
return -1;
}
}
else
{
//.........这里部分代码省略.........
开发者ID:jbunzel,项目名称:MvcRQ_git,代码行数:101,代码来源:EqualityHelper.cs
示例18: IsValidArgumentPair
/// <summary>
/// Determines whether the Arguments are valid
/// </summary>
/// <param name="stringLit">String Literal</param>
/// <param name="argLit">Argument Literal</param>
/// <returns></returns>
protected bool IsValidArgumentPair(ILiteralNode stringLit, ILiteralNode argLit)
{
if (stringLit.DataType != null)
{
//If 1st argument has a DataType must be an xsd:string or not valid
if (!stringLit.DataType.ToString().Equals(XmlSpecsHelper.XmlSchemaDataTypeString)) return false;
if (argLit.DataType != null)
{
//If 2nd argument also has a DataType must also be an xsd:string or not valid
if (!argLit.DataType.ToString().Equals(XmlSpecsHelper.XmlSchemaDataTypeString)) return false;
return true;
}
else if (argLit.Language.Equals(string.Empty))
{
//If 2nd argument does not have a DataType but 1st does then 2nd argument must have no
//Language Tag
return true;
}
else
{
//2nd argument does not have a DataType but 1st does BUT 2nd has a Language Tag so invalid
return false;
}
}
else if (!stringLit.Language.Equals(string.Empty))
{
if (argLit.DataType != null)
{
//If 1st argument has a Language Tag and 2nd Argument is typed then must be xsd:string
//to be valid
return argLit.DataType.ToString().Equals(XmlSpecsHelper.XmlSchemaDataTypeString);
}
else if (argLit.Language.Equals(string.Empty) || stringLit.Language.Equals(argLit.Language))
{
//If 1st argument has a Language Tag then 2nd Argument must have same Language Tag
//or no Language Tag in order to be valid
return true;
}
else
{
//Otherwise Invalid
return false;
}
}
else
{
if (argLit.DataType != null)
{
//If 1st argument is plain literal then 2nd argument must be xsd:string if typed
return argLit.DataType.ToString().Equals(XmlSpecsHelper.XmlSchemaDataTypeString);
}
else if (argLit.Language.Equals(string.Empty))
{
//If 1st argument is plain literal then 2nd literal cannot have a language tag to be valid
return true;
}
else
{
//If 1st argument is plain literal and 2nd has language tag then invalid
return false;
}
}
}
开发者ID:jmahmud,项目名称:RDFer,代码行数:70,代码来源:BaseBinaryStringFunction.cs
示例19: FormatLiteralNode
/// <summary>
/// Formats a Literal Node as a String
/// </summary>
/// <param name="l">Literal Node</param>
/// <param name="segment">Triple Segment</param>
/// <returns></returns>
protected override string FormatLiteralNode(ILiteralNode l, TripleSegment? segment)
{
StringBuilder output = new StringBuilder();
String value, qname;
bool longlit = false, plainlit = false;
longlit = TurtleSpecsHelper.IsLongLiteral(l.Value);
plainlit = TurtleSpecsHelper.IsValidPlainLiteral(l.Value, l.DataType);
if (plainlit)
{
if (TurtleSpecsHelper.IsValidDecimal(l.Value) && l.Value.EndsWith("."))
{
//Ensure we strip the trailing dot of any xsd:decimal and add a datatype definition
output.Append('"');
output.Append(l.Value.Substring(0, l.Value.Length - 1));
output.Append("\"^^<");
output.Append(this.FormatUri(XmlSpecsHelper.XmlSchemaDataTypeDecimal));
output.Append('>');
}
else
{
//Otherwise just write out the value
output.Append(l.Value);
}
//For integers ensure we insert a space after the literal to ensure it can't ever be confused with a decimal
if (TurtleSpecsHelper.IsValidInteger(l.Value))
{
output.Append(' ');
}
}
else
{
output.Append('"');
if (longlit) output.Append("\"\"");
value = l.Value;
bool fullyEscaped = (longlit) ? value.IsFullyEscaped(this._validEscapes, this._longLitMustEscape) : value.IsFullyEscaped(this._validEscapes, this._litMustEscape);
if (!fullyEscaped)
{
//This first replace escapes all back slashes for good measure
value = value.EscapeBackslashes(this._validEscapes);
//Then remove null character since it doesn't change the meaning of the Literal
value = value.Replace("\0", "");
//Don't need all the other escapes for long literals as the characters that would be escaped are permitted in long literals
//Need to escape " still
value = value.Escape('"');
if (!longlit)
{
//Then if we're not a long literal we'll escape tabs
value = value.Replace("\t", "\\t");
}
}
output.Append(value);
output.Append('"');
if (longlit) output.Append("\"\"");
if (!l.Language.Equals(String.Empty))
{
output.Append('@');
output.Append(l.Language.ToLower());
}
else if (l.DataType != null)
{
output.Append("^^");
if (this._qnameMapper.ReduceToQName(l.DataType.ToString(), out qname))
{
if (TurtleSpecsHelper.IsValidQName(qname))
{
output.Append(qname);
}
else
{
output.Append('<');
output.Append(this.FormatUri(l.DataType));
output.Append('>');
}
}
else
{
output.Append('<');
output.Append(this.FormatUri(l.DataType));
output.Append('>');
}
}
}
return output.ToString();
}
开发者ID:almostEric,项目名称:DotNetRDF-4.0,代码行数:100,代码来源:TurtleFormatter.cs
示例20: ToDouble
/// <summary>
/// Converts a Literal Node to a Double
/// </summary>
/// <param name="n">Literal Node</param>
/// <returns></returns>
public static Double ToDouble(ILiteralNode n)
{
if (n.DataType == null) throw new RdfQueryException("Cannot convert an untyped Literal to a Double");
return Double.Parse(n.Value);
}
开发者ID:jbunzel,项目名称:MvcRQ_git,代码行数:10,代码来源:SPARQLSpecsHelper.cs
注:本文中的ILiteralNode类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论