Exemplo n.º 1
0
        internal ItemsObject MapToItem(JSchema jSchema)
        {
            var item = new ItemsObject();

            item.Default = GetDefault(jSchema.Default);
            if (jSchema.Maximum.HasValue)
            {
                item.Maximum          = jSchema.Maximum;
                item.ExclusiveMaximum = jSchema.ExclusiveMaximum;
            }
            if (jSchema.Minimum.HasValue)
            {
                item.Minimum          = jSchema.Minimum;
                item.ExclusiveMinimum = jSchema.ExclusiveMinimum;
            }
            item.MaxLength = jSchema.MaximumLength;
            item.MinLength = jSchema.MinimumLength;
            item.Pattern   = jSchema.Pattern;
            item.MaxItems  = jSchema.MaximumItems;
            item.MinItems  = jSchema.MinimumItems;
            if (jSchema.UniqueItems) //If not present, this keyword may be considered present with boolean value false.
            {
                item.UniqueItems = jSchema.UniqueItems;
            }
            item.Enum = GetEnum(jSchema.Enum);
            item.Type = GetType(jSchema.Type);
            if (jSchema.Items.Count > 0)
            {
                item.Items = MapToItem(jSchema.Items.First());
            }
            return(item);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Gets the latest list of items from Steam.
        /// </summary>
        private static Dictionary <int, Item> GetGameItems()
        {
            string      response    = DownloadSteamAPIString(ITEMSURL, API);
            ItemsObject itemsObject = JsonConvert.DeserializeObject <ItemsObject>(response);

            Dictionary <int, Item> resultDic = new Dictionary <int, Item>();

            int    itemCountInt = 0;
            Item   Item;
            string rawItemName = "";

            foreach (var item in itemsObject.Result.Items)
            {
                rawItemName = item.Name.Replace("item_", "");
                // $"http://cdn.dota2.com/apps/dota2/images/items/{rawItemName}_lg.png";
                string itemImage = GetImageURL(Entity.items, rawItemName, ImageSize.lg);

                Item = new Item
                {
                    Name     = item.Localized_Name,
                    ID       = item.ID,
                    ImageURL = itemImage
                };

                resultDic.Add(item.ID, Item);
                itemCountInt++;
            }

            return(resultDic);
        }
Exemplo n.º 3
0
 public void Map(ItemsObject item)
 {
     Default          = item.Default;
     Maximum          = item.Maximum;
     ExclusiveMaximum = item.ExclusiveMaximum;
     Minimum          = item.Minimum;
     ExclusiveMinimum = item.ExclusiveMinimum;
     MaxLength        = item.MaxLength;
     MinLength        = item.MinLength;
     Pattern          = item.Pattern;
     MaxItems         = item.MaxItems;
     MinItems         = item.MinItems;
     UniqueItems      = item.UniqueItems;
     Enum             = item.Enum;
     Type             = item.Type;
     Items            = item.Items;
 }