Esempio n. 1
0
        /// <summary>
        /// Return the correct anime list based on the default value.
        /// </summary>
        /// <returns>The retrieved AnimeList</returns>
        private static AnimeList GetAnimeList()
        {
            var act = Settings.DefaultAnime;

            try {
                AnimeList list;
                switch (act?.Provider)
                {
                case "MyAnimeList":
                    list = AnimeList.Load(new MyAnimeList(act.Credentials));
                    break;

                case "Kitsu":
                    list = AnimeList.Load(new Kitsu(act.Credentials));
                    break;

                case "AniList":
                    var cli = new AniList(act);
                    cli.TokenExpired += OnAniListTokenExpired;
                    list              = AnimeList.Load(cli);
                    break;

                default:
                    return(null);
                }
                return(list);
            }
            catch (Exception e) {
                Debug.WriteLine(e.InnerException?.Message ?? e.Message);
                Debug.WriteLine(e.InnerException?.StackTrace ?? e.StackTrace);
                var md = new MessageDialog(Win, DialogFlags.DestroyWithParent, MessageType.Error, ButtonsType.YesNo,
                                           "An error was encountered while loading the default anime list: \n" + (e.InnerException?.Message ?? e.Message) +
                                           "\n Open the settings window?")
                {
                    WindowPosition = WindowPosition.Center
                };
                if (md.Run() == (int)ResponseType.Yes)
                {
                    md.Destroy();
                    var s = new SettingsWindow(false)
                    {
                        WindowPosition = WindowPosition.Center
                    };
                    if (s.Run() == (int)ResponseType.Accept)
                    {
                        SettingsChanged();
                    }
                    s.Destroy();
                }
                else
                {
                    md.Destroy();
                }
                return(null);
            }
        }
Esempio n. 2
0
 public void SetUpFirst()
 {
     Program.Init();
     _mal = new MyAnimeList(new UserPass("trackrtest", "MWhXDyAUQdxa"));
     Assert.True(_mal.VerifyCredentials().Result);
     _list = AnimeList.Load(_mal);
     TearDown();
 }
Esempio n. 3
0
        public User()
        {
            Settings = Trackr.Core.Settings.Load();
            IAnime anime = ResolveAnimeClient(Settings);

            if (anime != null)
            {
                AnimeList.Load(anime);
            }
            IManga manga = ResolveMangaClient(Settings);

            if (manga != null)
            {
                MangaList.Load(manga);
            }
        }
Esempio n. 4
0
        public static void Main()
        {
            Program.Init();
            var mal = new MyAnimeList(new UserPass("trackrtest", "MWhXDyAUQdxa"));

            Assert(mal.VerifyCredentials().Result);
            var list   = AnimeList.Load(mal);
            var result = list.Find("Bleach").Result;

            Assert(result.Count > 0);
            list.Add(result[0]);
            Assert(list.Contains(result[0]));
            Assert(list.Sync().Result);
            var pull = mal.PullAnimeList().Result;

            Assert(pull.Contains(result[0]));
            list.Remove(result[0]);
            Assert(!list.Contains(result[0]));
            Assert(list.Sync().Result);
            pull = mal.PullAnimeList().Result;
            Assert(!pull.Contains(result[0]));
            Console.WriteLine("Test pass!");
        }