Exemplo n.º 1
0
        public void GetItems()
        {
            ApiService.ApiKey = APIKEY;                                                            //you must add your project, if you dont use ninject
            StaticApi staticapi = new StaticApi(new ApiCache());
            Items     data      = staticapi.GetItems(region.tr, language.tr_TR, itemListData.all); // null is basic information

            Assert.IsTrue(data.Data.Count > 0);
        }
Exemplo n.º 2
0
        public void GetLanguageStrings()
        {
            ApiService.ApiKey = APIKEY;//you must add your project, if you dont use ninject
            StaticApi       staticapi = new StaticApi(new ApiCache());
            LanguageStrings data      = staticapi.GetLanguageStrings(region.tr, language.tr_TR);

            Assert.IsTrue(data.Data.Count > 0);
        }
 Realm GetRealm(Region reg)
 {
     try
     {
         return(StaticApi.GetRealm(reg));
     }
     catch (Exception ex)
     {
         BaseInstance.Log("Failed to get DataDragon Realm", ex);
     }
     return(null);
 }
Exemplo n.º 4
0
        public MainViewModel(RiotApi apiInstance, StaticApi staticApiInstance)
        {
            api       = apiInstance;
            staticApi = staticApiInstance;

            RegionList = new ObservableCollection <Region>();
            RegionList.Add(new Region("NA", "na1"));
            RegionList.Add(new Region("EUW", "euw1"));
            RegionList.Add(new Region("EUN", "eun1"));
            RegionList.Add(new Region("KR", "kr"));
            Region = RegionList[0];
        }
Exemplo n.º 5
0
        private string GetUrlImage(int iconId)
        {
            var    version       = StaticApi.GetVersions(Region.euw);
            string versionNumber = version.FirstOrDefault();

            if (versionNumber != null)
            {
                return(String.Format(Config.Read(Config.ConfigKeys.ImagesUrl), versionNumber, iconId));
            }
            else
            {
                return("");
            }
        }
Exemplo n.º 6
0
 protected virtual void GenerateStaticApiRedirection(StaticApi api, Declaration input_decl, CodeWriter s)
 {
     foreach (var decl in ExpandOverloads(input_decl))
     {
         var retval      = GenerateReturnType(decl);
         var arguments   = GenerateArguments(decl);
         var passed_args = GeneratePassedArgs(decl);
         GenerateDocString(decl, s);
         var generics = decl.Generics == null ? "" : $"<{string.Join(",", decl.Generics)}>";
         s.Out($"public static {retval} {decl.Name}{generics}({arguments})");
         s.Indent(() => s.Out(
                      $"=> {api.SingletonName}.Instance.{decl.Name}({passed_args});"));
         s.AppendLine();
     }
 }
Exemplo n.º 7
0
        public async Task <IHttpActionResult> Get()
        {
            List <Champion> list = new List <Champion>();
            var             championsStaticList = StaticApi.GetChampions(Region.euw, RiotSharp.StaticDataEndpoint.ChampionData.image, Language.es_ES);

            foreach (var champ in championsStaticList.Champions)
            {
                list.Add(new Champion()
                {
                    ID       = champ.Value.Id,
                    ImageUrl = String.Format("http://ddragon.leagueoflegends.com/cdn/{0}/img/champion/{1}", championsStaticList.Version, champ.Value.Image.Full),
                    Name     = champ.Value.Name,
                    Disabled = true
                });
            }
            return(this.Ok(list));
        }
Exemplo n.º 8
0
 public virtual void GenerateStaticApi(StaticApi api, CodeWriter s)
 {
     GenerateUsings(s);
     s.Out($"namespace {NameSpace}");
     s.Block(() =>
     {
         s.Out($"public static partial class {api.StaticName}");
         s.Block(() =>
         {
             s.Break();
             foreach (var decl in api.Declarations)
             {
                 GenerateStaticApiRedirection(api, decl, s);
             }
             s.Break();
         });
     });
 }
        public void UpdateSpells()
        {
            UpdateStatus("Updating spells...");
            SummonerSpellListStatic spells = StaticApi.GetSummonerSpells(_basereg, SummonerSpellData.image);
            int    i    = 0;
            double prog = 0;

            foreach (KeyValuePair <string, SummonerSpellStatic> sp in spells.SummonerSpells)
            {
                i++;
                prog = (double)i / spells.SummonerSpells.Count;
                UpdateProgress((int)(prog * 100));

                if (!File.Exists(SpellsDirectory + @"\" + sp.Value.Id.ToString() + ".png"))
                {
                    UpdateStatus("Spell " + sp.Value.Id.ToString() + ".png");
                    _wbc.DownloadFile(DataDragonRealm.Cdn + "/" + DataDragonRealm.Dd + "/img/spell/" + sp.Value.Image.Full, SpellsDirectory + @"\" + sp.Value.Id.ToString() + ".png");
                }
            }
            UpdateStatus("Spells Updated");
        }
Exemplo n.º 10
0
        public void UpdateItems()
        {
            UpdateStatus("Updating items...");
            int            i     = 0;
            double         prog  = 0;
            ItemListStatic items = StaticApi.GetItems(_basereg, ItemData.image);

            foreach (KeyValuePair <int, ItemStatic> it in items.Items)
            {
                i++;
                prog = (double)i / items.Items.Count;
                UpdateProgress((int)(prog * 100));

                if (!File.Exists(ItemsDirectory + @"\" + it.Value.Id.ToString() + ".png"))
                {
                    _wbc.DownloadFile(DataDragonRealm.Cdn + "/" + DataDragonRealm.Dd + "/img/item/" + it.Value.Image.Full, ItemsDirectory + @"\" + it.Value.Id.ToString() + ".png");
                    UpdateStatus("Item " + it.Value.Id.ToString() + ".png");
                }
            }
            UpdateStatus("Items Updated");
        }
Exemplo n.º 11
0
        public static void StreakCheck(
            [Description("The summoner of which the game should be waited for")]
            string username,
            [Description("Shows only enemy summoners")]
            bool enemyOnly)
        {
            var summoner = Helper.TryApi(() => Api.GetSummoner(Settings.Default.Region, username));

            if (summoner == null)
            {
                Console.WriteLine("No such summoner found.");
                return;
            }

            var game = Helper.TryApi(() => Api.GetCurrentGame(Platform, summoner.Id));

            if (game == null)
            {
                Console.WriteLine("No game found.");
                return;
            }

            var ownTeam = game.Participants
                          .Single(o => o.SummonerId == summoner.Id).TeamId;

            foreach (var p in game.Participants
                     .Where(o => !o.Bot))
            {
                if (!enemyOnly || ownTeam != p.TeamId)
                {
                    var champ           = Helper.TryApi(() => StaticApi.GetChampion(Settings.Default.Region, (int)p.ChampionId), 2);
                    var recents         = Helper.TryApi(() => Api.GetRecentGames(Settings.Default.Region, p.SummonerId), 2);
                    var recentWins      = recents.Select(o => o.Statistics.Win);
                    var isWinningStreak = recentWins.FirstOrDefault();
                    var streakCount     = recentWins.TakeWhile(o => o == isWinningStreak).Count();
                    Console.WriteLine("{0,-20} ({1,-15}) is on a {2} streak with {3,2} games",
                                      p.SummonerName, champ.Name, isWinningStreak ? "winning" : "losing ", streakCount);
                }
            }
        }
Exemplo n.º 12
0
 public virtual void GenerateStaticApi(StaticApi api, CodeWriter s)
 {
     GenerateUsings(s);
     s.Out($"namespace {NameSpace}");
     s.Block(() =>
     {
         s.Out($"public static partial class {api.StaticName}");
         s.Block(() =>
         {
             s.Break();
             foreach (var decl in api.Declarations)
             {
                 try
                 {
                     if (decl.Ignore)
                     {
                         continue;
                     }
                     GenerateApiFunction(decl, s, @static: true);
                 }
                 catch (Exception e)
                 {
                     s.Out("// Error generating delaration: " + decl.Name);
                     s.Out("// Message: " + e.Message);
                     s.Out("/*");
                     s.Out(e.StackTrace);
                     s.Out("----------------------------");
                     s.Out("Declaration JSON:");
                     s.Out(JObject.FromObject(decl).ToString(Formatting.Indented));
                     s.Out("*/");
                 }
             }
             s.Break();
         });
     });
 }
Exemplo n.º 13
0
        public string Generate()
        {
            var docs = LoadDocs();
            var api  = new StaticApi()
            {
                StaticName   = "np",    // name of the static API class
                ImplName     = "NumPy", // name of the singleton that implements the static API behind the scenes
                PythonModule = "numpy"  // name of the Python module that the static api wraps
            };

            _generator.StaticApis.Add(api);
            foreach (var html_doc in docs)
            {
                var doc = html_doc.Doc;
                // declaration
                var h1 = doc.DocumentNode.Descendants("h1").FirstOrDefault();
                if (h1 == null)
                {
                    continue;
                }
                var dl = doc.DocumentNode.Descendants("dl").FirstOrDefault();
                if (dl == null || dl.Attributes["class"]?.Value != "function")
                {
                    continue;
                }
                var class_name = doc.DocumentNode.Descendants("code")
                                 .First(x => x.Attributes["class"]?.Value == "descclassname").InnerText;
                var func_name = doc.DocumentNode.Descendants("code")
                                .First(x => x.Attributes["class"]?.Value == "descname").InnerText;
                var decl = new Declaration()
                {
                    Name = func_name, ClassName = class_name.TrimEnd('.')
                };
                // function description
                var dd = dl.Descendants("dd").FirstOrDefault();
                decl.Description = ParseDescription(dd);
                var table = doc.DocumentNode.Descendants("table")
                            .FirstOrDefault(x => x.Attributes["class"]?.Value == "docutils field-list");
                if (table == null)
                {
                    continue;
                }
                // arguments
                ParseArguments(html_doc, table, decl);

                // return type(s)
                ParseReturnTypes(html_doc, table, decl);

                PostProcess(decl);
                // if necessary create overloads
                foreach (var d in InferOverloads(decl))
                {
                    api.Declarations.Add(d);
                }
            }
            var dir     = Directory.GetCurrentDirectory();
            var src_dir = dir.Substring(0, dir.LastIndexOf("\\src\\")) + "\\src\\";

            api.OutputPath = Path.Combine(src_dir, "Torch");
            _generator.Generate();
            return("DONE");
        }
Exemplo n.º 14
0
 public void Init()
 {
     instance = new StaticApi();
 }
Exemplo n.º 15
0
 public StaticApiTests()
 {
     instance = new StaticApi();
 }