本文整理汇总了C#中RavenJToken.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# RavenJToken.ToString方法的具体用法?C# RavenJToken.ToString怎么用?C# RavenJToken.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RavenJToken
的用法示例。
在下文中一共展示了RavenJToken.ToString方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WriteValue
private static void WriteValue(RavenJToken token, CountingWriter sw, int width, int numberOfLines)
{
switch (token.Type)
{
case JTokenType.Array:
WriteJsonArray((RavenJArray)token, sw, width, numberOfLines);
break;
case JTokenType.Object:
WriteJsonObject((RavenJObject)token, sw, width, numberOfLines);
break;
case JTokenType.Null:
sw.Write("null");
break;
case JTokenType.String:
sw.Write("\"");
sw.Write(token.ToString()
.NormalizeWhitespace()
.TrimmedViewOfString(width - sw.CharactersOnCurrentLine -1)
);
sw.Write("\"");
break;
default:
sw.Write(token.ToString().TrimmedViewOfString(width - sw.CharactersOnCurrentLine - 1));
break;
}
}
示例2: WriteValue
private static void WriteValue(RavenJToken token, StringWriter sw, int margin, int indent)
{
switch (token.Type)
{
case JTokenType.Array:
WriteJsonArray((RavenJArray)token, sw, margin, indent);
break;
case JTokenType.Object:
WriteJsonObject((RavenJObject)token, sw, margin, indent);
break;
case JTokenType.Null:
sw.Write("null");
break;
case JTokenType.String:
sw.Write('"');
sw.Write(token.ToString()
.NormalizeWhitespace()
.ShortViewOfString(margin - 2)
);
sw.Write('"');
break;
default:
sw.Write(token.ToString().ShortViewOfString(margin));
break;
}
}
示例3: StripQuotesIfNeeded
private static string StripQuotesIfNeeded(RavenJToken value)
{
var str = value.ToString(Formatting.None);
if (str.StartsWith("\"") && str.EndsWith("\""))
return str.Substring(1, str.Length - 2);
return str;
}
示例4: GetPropertyValue
private static object GetPropertyValue(RavenJToken property)
{
switch (property.Type)
{
case JTokenType.Array:
case JTokenType.Object:
return property.ToString(Formatting.None);
default:
return property.Value<object>();
}
}
示例5: GetTokenValue
private static object GetTokenValue(RavenJToken token)
{
if (token == null)
{
return "";
}
switch (token.Type)
{
case JTokenType.Object:
case JTokenType.Array:
case JTokenType.Constructor:
case JTokenType.Property:
case JTokenType.Comment:
case JTokenType.Raw:
case JTokenType.Bytes:
case JTokenType.Uri:
return token.ToString(Formatting.None);
case JTokenType.Integer:
return token.Value<int>();
case JTokenType.Float:
return token.Value<double>();
case JTokenType.String:
return token.Value<string>();
case JTokenType.Boolean:
return token.Value<bool>();
case JTokenType.Date:
return token.Value<DateTime>();
case JTokenType.Guid:
return token.Value<Guid>();
case JTokenType.TimeSpan:
return token.Value<TimeSpan>();
default:
return "";
}
}