當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。