本文整理汇总了C#中Newtonsoft.Json.Linq.JTokenReader.Skip方法的典型用法代码示例。如果您正苦于以下问题:C# JTokenReader.Skip方法的具体用法?C# JTokenReader.Skip怎么用?C# JTokenReader.Skip使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Newtonsoft.Json.Linq.JTokenReader
的用法示例。
在下文中一共展示了JTokenReader.Skip方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ReadMetadataPropertiesToken
private bool ReadMetadataPropertiesToken(JTokenReader reader, ref Type objectType, ref JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, object existingValue, out object newValue, out string id)
{
id = null;
newValue = null;
if (reader.TokenType == JsonToken.StartObject)
{
JObject current = (JObject)reader.CurrentToken;
JToken refToken = current[JsonTypeReflector.RefPropertyName];
if (refToken != null)
{
if (refToken.Type != JTokenType.String && refToken.Type != JTokenType.Null)
throw JsonSerializationException.Create(refToken, refToken.Path, "JSON reference {0} property must have a string or null value.".FormatWith(CultureInfo.InvariantCulture, JsonTypeReflector.RefPropertyName), null);
JToken property = refToken.Parent;
JToken additionalContent = null;
if (property.Next != null)
additionalContent = property.Next;
else if (property.Previous != null)
additionalContent = property.Previous;
string reference = (string)refToken;
if (reference != null)
{
if (additionalContent != null)
throw JsonSerializationException.Create(additionalContent, additionalContent.Path, "Additional content found in JSON reference object. A JSON reference object should only have a {0} property.".FormatWith(CultureInfo.InvariantCulture, JsonTypeReflector.RefPropertyName), null);
newValue = Serializer.GetReferenceResolver().ResolveReference(this, reference);
if (TraceWriter != null && TraceWriter.LevelFilter >= TraceLevel.Info)
TraceWriter.Trace(TraceLevel.Info, JsonPosition.FormatMessage(reader as IJsonLineInfo, reader.Path, "Resolved object reference '{0}' to {1}.".FormatWith(CultureInfo.InvariantCulture, reference, newValue.GetType())), null);
reader.Skip();
return true;
}
}
JToken typeToken = current[JsonTypeReflector.TypePropertyName];
if (typeToken != null)
{
string qualifiedTypeName = (string)typeToken;
JsonReader typeTokenReader = typeToken.CreateReader();
CheckedRead(typeTokenReader);
ResolveTypeName(typeTokenReader, ref objectType, ref contract, member, containerContract, containerMember, qualifiedTypeName);
JToken valueToken = current[JsonTypeReflector.ValuePropertyName];
if (valueToken != null)
{
while (true)
{
CheckedRead(reader);
if (reader.TokenType == JsonToken.PropertyName)
{
if ((string)reader.Value == JsonTypeReflector.ValuePropertyName)
return false;
}
CheckedRead(reader);
reader.Skip();
}
}
}
JToken idToken = current[JsonTypeReflector.IdPropertyName];
if (idToken != null)
{
id = (string)idToken;
}
JToken valuesToken = current[JsonTypeReflector.ArrayValuesPropertyName];
if (valuesToken != null)
{
JsonReader listReader = valuesToken.CreateReader();
CheckedRead(listReader);
newValue = CreateList(listReader, objectType, contract, member, existingValue, id);
reader.Skip();
return true;
}
}
CheckedRead(reader);
return false;
}
示例2: ReadMetadataPropertiesToken
// Token: 0x06000BC0 RID: 3008
// RVA: 0x00043F40 File Offset: 0x00042140
private bool ReadMetadataPropertiesToken(JTokenReader reader, ref Type objectType, ref JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, object existingValue, out object newValue, out string id)
{
id = null;
newValue = null;
if (reader.TokenType == JsonToken.StartObject)
{
JObject jObject = (JObject)reader.CurrentToken;
JToken jToken = jObject["$ref"];
if (jToken != null)
{
if (jToken.Type != JTokenType.String && jToken.Type != JTokenType.Null)
{
throw JsonSerializationException.Create(jToken, jToken.Path, StringUtils.FormatWith("JSON reference {0} property must have a string or null value.", CultureInfo.InvariantCulture, "$ref"), null);
}
JToken parent = jToken.Parent;
JToken jToken2 = null;
if (parent.Next != null)
{
jToken2 = parent.Next;
}
else if (parent.Previous != null)
{
jToken2 = parent.Previous;
}
string text = (string)jToken;
if (text != null)
{
if (jToken2 != null)
{
throw JsonSerializationException.Create(jToken2, jToken2.Path, StringUtils.FormatWith("Additional content found in JSON reference object. A JSON reference object should only have a {0} property.", CultureInfo.InvariantCulture, "$ref"), null);
}
newValue = this.Serializer.GetReferenceResolver().ResolveReference(this, text);
if (this.TraceWriter != null && this.TraceWriter.LevelFilter >= TraceLevel.Info)
{
this.TraceWriter.Trace(TraceLevel.Info, JsonPosition.FormatMessage(reader, reader.Path, StringUtils.FormatWith("Resolved object reference '{0}' to {1}.", CultureInfo.InvariantCulture, text, newValue.GetType())), null);
}
reader.Skip();
return true;
}
}
JToken jToken3 = jObject["$type"];
if (jToken3 != null)
{
string qualifiedTypeName = (string)jToken3;
JsonReader reader2 = jToken3.CreateReader();
this.CheckedRead(reader2);
this.ResolveTypeName(reader2, ref objectType, ref contract, member, containerContract, containerMember, qualifiedTypeName);
JToken jToken4 = jObject["$value"];
if (jToken4 != null)
{
while (true)
{
this.CheckedRead(reader);
if (reader.TokenType == JsonToken.PropertyName && (string)reader.Value == "$value")
{
break;
}
this.CheckedRead(reader);
reader.Skip();
}
return false;
}
}
JToken jToken5 = jObject["$id"];
if (jToken5 != null)
{
id = (string)jToken5;
}
JToken jToken6 = jObject["$values"];
if (jToken6 != null)
{
JsonReader reader3 = jToken6.CreateReader();
this.CheckedRead(reader3);
newValue = this.CreateList(reader3, objectType, contract, member, existingValue, id);
reader.Skip();
return true;
}
}
this.CheckedRead(reader);
return false;
}