コード例 #1
0
        public static async Task <IEnumerable <IItem> > GetItemsStaticInfosAsync(
            this IHasItemIds hasItemIds,
            ItemDataEnum?itemData     = null,
            RegionEnum?region         = null,
            LanguageEnum?languageCode = null,
            string dataDragonVersion  = null)
        {
            if (hasItemIds == null)
            {
                throw new ArgumentNullException("hasItemIds");
            }

            var result = new List <IItem>();

            var staticService = new StaticService(hasItemIds.ApiConfiguration);

            foreach (var itemId in hasItemIds.ItemIds.Where(x => x > 0))
            {
                var item = await staticService.GetItemsAsync(
                    itemId,
                    itemData,
                    region,
                    languageCode,
                    dataDragonVersion);

                result.Add(item);
            }

            return(result);
        }
コード例 #2
0
        public static async Task <IEnumerable <string> > GetItemsImageUrlsAsync(
            this IHasItemIds hasItemIds,
            RegionEnum?region        = null,
            string dataDragonVersion = null)
        {
            if (hasItemIds == null)
            {
                throw new ArgumentNullException("hasItemIds");
            }

            var staticService = new StaticService(hasItemIds.ApiConfiguration);

            if (string.IsNullOrWhiteSpace(dataDragonVersion))
            {
                var realm = await staticService.GetRealmAsync(region);

                dataDragonVersion = realm.CurrentVersion;
            }

            return(hasItemIds.ItemIds
                   .Where(x => x > 0)
                   .Select(x =>
                           string.Format("http://ddragon.leagueoflegends.com/cdn/{0}/img/item/{1}.png",
                                         dataDragonVersion,
                                         x)));
        }