AniDBmini.AniDBAPI.RandomAnime C# (CSharp) Method

RandomAnime() public method

Retrieves a random anime from a certian criteria.
public RandomAnime ( int type ) : void
type int type: 0=from db, 1=watched, 2=unwatched, 3=all mylist
return void
        public void RandomAnime(int type)
        {
            Action random = new Action(delegate
            {
                APIResponse response = Execute(String.Format("RANDOMANIME type={0}", type));
                if (response.Code == RETURN_CODE.ANIME)
                {
                    Action anime = new Action(delegate { Anime(int.Parse(Regex.Split(response.Message, "\n")[1].Split('|')[0])); });
                    PrioritizedCommand(anime);
                }
            });

            PrioritizedCommand(random);
        }

Usage Example

        private void randomAnimeLabelContextMenuItem_Click(object sender, RoutedEventArgs e)
        {
            MenuItem mi = (MenuItem)sender;

            m_aniDBAPI.RandomAnime(int.Parse(mi.Tag.ToString()));
        }