本文整理汇总了C#中Literal.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# Literal.ToString方法的具体用法?C# Literal.ToString怎么用?C# Literal.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Literal
的用法示例。
在下文中一共展示了Literal.ToString方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetLiteralHash
// Computes a hash for a literal value to put in the hash column of the _literals table.
private string GetLiteralHash(Literal literal) {
byte[] data = System.Text.Encoding.Unicode.GetBytes(literal.ToString());
byte[] hash = sha.ComputeHash(data);
return Convert.ToBase64String(hash);
}
示例2: VisitLiteral
public override Expression VisitLiteral (Literal literal) {
if (this._string == null){ this._string = new StringBuilder(); }
if (literal.Value == null) {
this._string.Append("null");
}
else if (literal.Value is string) {
this._string.AppendFormat("\"{0}\"", literal.Value.ToString());
}
else if (literal.Value is char) {
char c = (char)literal.Value;
if ((int)c <= 16384) {
// This number must match the one in Tab.cs in our version of
// Coco as the value of the field "charSetSize" in the class
// CharClass.
this._string.AppendFormat("'{0}'", literal.Value.ToString());
} else {
int cValue = c;
this._string.AppendFormat("'\\u{0}'", cValue.ToString());
}
}
else if (literal.Value is string) {
this._string.AppendFormat("\"{0}\"", literal.Value.ToString());
}
else if (literal.Value is TypeNode){
TypeNode t = literal.Value as TypeNode;
this.AddType(t);
}else{
this._string.Append(literal.ToString());
}
return literal;
}