コード例 #1
0
ファイル: Home.xaml.cs プロジェクト: AmalShaiju/AnimeNorth
        private async Task <List <Button> > SetDummmyOptionsAsync()
        {
            List <Button> buttonsToreturn = new List <Button>();
            AnimeById     anime           = new AnimeById();

            // populate options with random Titles
            for (int i = 0; i < 3; i++)
            {
                try
                {
                    // get the anime with the random id
                    anime = await AnimeRepository.GetAnimeAsync(random.Next(1000));
                }
                catch
                {
                    // if no anime exist with generated random int
                    // get the anime with the random id
                    anime = await AnimeRepository.GetAnimeAsync(random.Next(100, 107));
                }
                finally
                {
                    if (options.Contains(anime.Data.Attributes.Titles.EnJp))
                    {
                        anime = await AnimeRepository.GetAnimeAsync(random.Next(1, 20));
                    }

                    options.Add(anime.Data.Attributes.Titles.EnJp);

                    // Create a btn and add to the button list
                    buttonsToreturn.Add(createbtn(anime.Data.Attributes.Titles.EnJp, Color.Transparent, Color.Red));
                }
            }

            return(buttonsToreturn);
        }
コード例 #2
0
ファイル: Home.xaml.cs プロジェクト: AmalShaiju/AnimeNorth
        private async Task <string> GetAnimeSynopsisAsync()
        {
            AnimeById anime = new AnimeById();

            // get an anime save the asnwer and return the synopsis
            try
            {
                anime = await AnimeRepository.GetAnimeAsync(random.Next(1000));
            }
            catch
            {
                // if no anime exist for the random id get one from hard coded
                anime = await AnimeRepository.GetAnimeAsync(random.Next(100, 107));
            }
            finally
            {
                // if the synopsis is too short
                if (anime.Data.Attributes.Synopsis.Length < 100)
                {
                    anime = await AnimeRepository.GetAnimeAsync(random.Next(1, 20));
                }

                this.Answer = anime.Data.Attributes.Titles.EnJp;

                // Create a btn with the answer as txt
                this.buttons.Add(createbtn(anime.Data.Attributes.Titles.EnJp, Color.Transparent, Color.Red));
            }

            return(anime.Data.Attributes.Synopsis);
        }