コード例 #1
0
        public void GetRealm_Test()
        {
            var realm = api.GetRealm(Region.euw);

            Assert.IsNotNull(realm);
        }
コード例 #2
0
ファイル: StaticDataStore.cs プロジェクト: Kyle0654/probuilds
        /// <summary>
        /// Initialize the static data store by pulling down all data we care about.
        /// </summary>
        public static void Initialize(StaticRiotApi riotStaticApi)
        {
            var realms = Enum.GetValues(typeof(Region)).OfType <Region>().AsParallel().WithDegreeOfParallelism(4).Select(region => new { Region = region, Realm = riotStaticApi.GetRealm(region) }).ToList();

            Version = realms.Max(realm => new RiotVersion(realm.Realm.V));
            var filteredRealms = realms.Where(realm => Version.IsSamePatch(new RiotVersion(realm.Realm.V)));

            // Get data for all valid realms
            Realms = filteredRealms.ToDictionary(realm => realm.Region, realm => new RealmStaticData(riotStaticApi, realm.Realm, realm.Region));

            // Try getting NA data if available
            RealmStaticData primaryrealm;

            if (!Realms.TryGetValue(Region.na, out primaryrealm))
            {
                // Try to find an english realm
                primaryrealm = Realms.FirstOrDefault(kvp => kvp.Value.Realm.L.Contains("en")).Value;

                // If we can't find english data, give up and just choose the first realm
                if (primaryrealm == null)
                {
                    primaryrealm = Realms.FirstOrDefault().Value;
                }

                // If there are no realms, just return
                if (primaryrealm == null)
                {
                    return;
                }
            }

            Champions      = primaryrealm.Champions;
            Items          = primaryrealm.Items;
            SummonerSpells = primaryrealm.SummonerSpells;
        }