Esempio n. 1
0
        public override object ReadJson(JsonReader reader, Type objectType, object existingValue, Newtonsoft.Json.JsonSerializer serializer)
        {
            var result = new List <ItemJsonModel>();

            if (reader.TokenType == JsonToken.StartObject)
            {
                JObject root  = JObject.Load(reader);
                var     items = root.Properties().First().First().Values();
                foreach (var item in items)
                {
                    var itemData = new ItemJsonModel
                    {
                        ItemId      = item["id"].ToString(),
                        Name        = item["dname"].ToString(),
                        Attributes  = item["attrib"].ToString(),
                        Cost        = item["cost"].ToString(),
                        Description = item["desc"].ToString(),
                        Lore        = item["lore"].ToString(),
                        Image       = item["img"].ToString(),
                        Cooldown    = item["cd"].ToString(),
                        ManaCost    = item["mc"].ToString(),
                        Notes       = item["notes"].ToString(),
                        Quality     = item["qual"].ToString()
                    };

                    result.Add(itemData);
                }
            }

            return(result);
        }
Esempio n. 2
0
        public string ToJson()
        {
            var model = new ItemSetJsonModel();
            model.title = Title;
            model.type = "custom";
            model.map = "SR";
            model.mode = "CLASSIC";
            model.priority = false;
            model.sortrank = 0;
            model.blocks = new ItemBlockJsonModel[ItemBlocks.Count];
            for(int itemBlockIndex = 0; itemBlockIndex < ItemBlocks.Count; itemBlockIndex++)
            {
                var itemBlockJsonModel = new ItemBlockJsonModel();
                itemBlockJsonModel.type = ItemBlocks[itemBlockIndex].Name;
                itemBlockJsonModel.hideIfSummonerSpell = "";
                itemBlockJsonModel.showIfSummonerSpell = "";
                itemBlockJsonModel.maxSummonerLevel = -1;
                itemBlockJsonModel.minSummonerLevel = -1;
                itemBlockJsonModel.recMath = false;

                var items = new ItemJsonModel[ItemBlocks[itemBlockIndex].Items.Count];
                for (int itemIndex = 0; itemIndex < ItemBlocks[itemBlockIndex].Items.Count; itemIndex++)
                {
                    var itemJsonModel = new ItemJsonModel();
                    itemJsonModel.id = ItemBlocks[itemBlockIndex].Items[itemIndex].Id.ToString();
                    itemJsonModel.count = 1;
                    items[itemIndex] = itemJsonModel;
                }

                itemBlockJsonModel.items = items;

                model.blocks[itemBlockIndex] = itemBlockJsonModel;
            }

            return JsonConvert.SerializeObject(model, Formatting.Indented);
        }