当前位置: 首页>>代码示例>>C#>>正文


C# JsonReader.ReadInt32方法代码示例

本文整理汇总了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();
            }
        }
开发者ID:KevinAllenWiegand,项目名称:SaintCoinach,代码行数:23,代码来源:Item.Parse.cs

示例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 };
        }
开发者ID:KevinAllenWiegand,项目名称:SaintCoinach,代码行数:12,代码来源:Item.Parse.cs

示例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);
        }
开发者ID:KevinAllenWiegand,项目名称:SaintCoinach,代码行数:12,代码来源:Item.Parse.cs

示例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;
        }
开发者ID:KevinAllenWiegand,项目名称:SaintCoinach,代码行数:39,代码来源:Item.Parse.cs


注:本文中的Newtonsoft.Json.JsonReader.ReadInt32方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。