Skip to content

GetSingleCategoryRecords() is doesn't working in WinForms #11

Description

@FlashJ1

Hi, mirrorcult! In my project (WinForms .net framework 4.8 is required in NuGet) I can't init Leaderboard, but in console is working no problem. He's throwing except about GenericArguments[0], Nullable TClass

using SpeedrunDotComAPI;
using SpeedrunDotComAPI.Categories;
using SpeedrunDotComAPI.Games;
using SpeedrunDotComAPI.Leaderboards;
using SpeedrunDotComAPI.Runs;
using SpeedrunDotComAPI.Links;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Text.Json;

namespace SpeedrunDotCom_APP2
{
    public partial class Form1 : Form
    {
        public SRCApiClient src;

        public CategoryModel[] categories;
        public Form1()
        {
            InitializeComponent();

            src = new SRCApiClient();

        }

        private async void btFind_Click(object sender, EventArgs e)
        {
            

            cbCategories.Items.Clear();

            string gameName = tbSearchGame.Text;

            //GameModel[] filteredGame = await src.Games.GetAllGames(new GameFilterOptions() { Name = gameName, _Bulk = true });

            CategoryModel[] categories = await src.Games.GetSingleGameCategories(gameName);

            if (categories == null)
            {
                MessageBox.Show("Failed ID");
            }
            else
            {
                MessageBox.Show("Success ID");
            }

                cbCategories.DisplayMember = "Name";

            foreach (var category in categories)
            {
                cbCategories.Items.Add(category);
            }
        }
        private async void cbCategories_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {

                //string gameName = tbSearchGame.Text;

                //CategoryModel currCategory = (CategoryModel)cbCategories.SelectedItem;

                //LeaderboardModel[] leaderboard = await src.Categories.GetSingleCategoryRecords(currCategory.Id);

                //Task t1 = Task.Run(() => { LeaderboardInitAsync(); });

                //LeaderboardModel[] leaderboard = await LeaderboardInitAsync();



                // this example is doesn't working neither

                CategoryModel[] sm64Categories = await src.Games.GetSingleGameCategories("sm64");
                CategoryModel seventyStar = sm64Categories.First(c => c.Name == "70 Star");
                LeaderboardModel[] leaderboards = await src.Categories.GetSingleCategoryRecords(seventyStar.Id); // Returns a list of leaderboards because of categories with ILs.
                RunPlaceModel worldRecord = leaderboards[0].Runs.First(r => r.Place == 1);


                //RunPlaceModel worldRecord = leaderboard[0].Runs.First(r => r.Place == 1);

                lbUsername.Text = worldRecord.Run.Comment;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.StackTrace);
                MessageBox.Show(ex.Message);
            }
            
        }
    }
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions