本文整理匯總了C#中Newtonsoft.Json.Linq.JProperty.ReadContentFrom方法的典型用法代碼示例。如果您正苦於以下問題:C# JProperty.ReadContentFrom方法的具體用法?C# JProperty.ReadContentFrom怎麽用?C# JProperty.ReadContentFrom使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Newtonsoft.Json.Linq.JProperty
的用法示例。
在下文中一共展示了JProperty.ReadContentFrom方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: Load
/// <summary>
/// Loads an <see cref="JProperty"/> from a <see cref="JsonReader"/>.
/// </summary>
/// <param name="reader">A <see cref="JsonReader"/> that will be read for the content of the <see cref="JProperty"/>.</param>
/// <returns>A <see cref="JProperty"/> that contains the JSON that was read from the specified <see cref="JsonReader"/>.</returns>
public static JProperty Load(JsonReader reader)
{
if (reader.TokenType == JsonToken.None)
{
if (!reader.Read())
throw new Exception("Error reading JProperty from JsonReader.");
}
if (reader.TokenType != JsonToken.PropertyName)
throw new Exception(
"Error reading JProperty from JsonReader. Current JsonReader item is not a property: {0}".FormatWith(
CultureInfo.InvariantCulture, reader.TokenType));
JProperty p = new JProperty((string)reader.Value);
p.SetLineInfo(reader as IJsonLineInfo);
if (!reader.Read())
throw new Exception("Error reading JProperty from JsonReader.");
p.ReadContentFrom(reader);
return p;
}