本文整理汇总了C#中Newtonsoft.Json.JsonReader.ReadInt32方法的典型用法代码示例。如果您正苦于以下问题:C# JsonReader.ReadInt32方法的具体用法?C# JsonReader.ReadInt32怎么用?C# JsonReader.ReadInt32使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Newtonsoft.Json.JsonReader
的用法示例。
在下文中一共展示了JsonReader.ReadInt32方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ParseSeriesBonus
private void ParseSeriesBonus(JsonReader r, SeriesBonus bonus)
{
if (!r.Read() || r.TokenType != JsonToken.StartArray) throw new InvalidOperationException();
while (r.Read() && r.TokenType != JsonToken.EndArray) {
if (r.TokenType != JsonToken.StartObject) throw new InvalidOperationException();
if (!r.Read() || r.TokenType != JsonToken.PropertyName) throw new InvalidOperationException();
var bonusKey = r.Value.ToString();
if (!r.Read() || r.TokenType != JsonToken.StartObject) throw new InvalidOperationException();
if (!r.Read() || r.TokenType != JsonToken.PropertyName) throw new InvalidOperationException();
var paramKey = Convert.ToInt32(r.Value);
var value = r.ReadInt32();
bonus.Bonuses.Add(new KeyValuePair<string, Bonus>(bonusKey, new Bonus { BaseParam = paramKey, Value = value }));
if (!r.Read() || r.TokenType != JsonToken.EndObject) throw new InvalidOperationException();
if (!r.Read() || r.TokenType != JsonToken.EndObject) throw new InvalidOperationException();
}
}
示例2: ParseBonus
private Bonus ParseBonus(JsonReader r)
{
if (r.TokenType != JsonToken.StartObject) throw new InvalidOperationException();
if (!r.Read() || r.TokenType != JsonToken.PropertyName) throw new InvalidOperationException();
var key = Convert.ToInt32(r.Value);
var value = r.ReadInt32();
if (!r.Read() || r.TokenType != JsonToken.EndObject) throw new InvalidOperationException();
return new Bonus { BaseParam = key, Value = value };
}
示例3: ParseColor
private System.Drawing.Color ParseColor(JsonReader reader)
{
if (!reader.Read() || reader.TokenType != JsonToken.StartArray) throw new InvalidOperationException();
var r = reader.ReadInt32();
var g = reader.ReadInt32();
var b = reader.ReadInt32();
if (!reader.Read() || reader.TokenType != JsonToken.EndArray) throw new InvalidOperationException();
return System.Drawing.Color.FromArgb(r, g, b);
}
示例4: ParseAction
private Action ParseAction(JsonReader r)
{
if (r.TokenType != JsonToken.StartObject) throw new InvalidOperationException();
if (!r.Read() || r.TokenType != JsonToken.PropertyName) throw new InvalidOperationException();
var paramKey = Convert.ToInt32(r.Value);
if (!r.Read()) throw new InvalidOperationException();
Action value;
if (r.TokenType == JsonToken.StartObject) {
var act = new RelativeAction { BaseParam = paramKey };
while (r.Read() && r.TokenType != JsonToken.EndObject) {
if (r.TokenType != JsonToken.PropertyName) throw new InvalidOperationException();
switch (r.Value.ToString()) {
case "rate":
act.Rate = r.ReadInt32();
break;
case "limit":
act.Limit = r.ReadInt32();
break;
default:
Console.Error.WriteLine("Unknown 'Item'.'action' data key: {0}", r.Value);
throw new NotSupportedException();
}
}
value = act;
} else if (r.TokenType == JsonToken.Integer || r.TokenType == JsonToken.String) {
value = new FixedAction { BaseParam = paramKey, Value = Convert.ToInt32(r.Value) };
} else
throw new InvalidOperationException();
if (!r.Read() || r.TokenType != JsonToken.EndObject) throw new InvalidOperationException();
return value;
}