Exemplo n.º 1
0
        public static string GetUrl(AnilistTypes anilistType, QueryType?queryType, object queryParameter)
        {
            switch (anilistType)
            {
            case AnilistTypes.Anime:
                return($"{AnimeUrl}{GetQueryTypeUrl(queryType, queryParameter)}");

            case AnilistTypes.Manga:
                return($"{MangaUrl}{GetQueryTypeUrl(queryType, queryParameter)}");

            case AnilistTypes.Actor:
                return($"{ActorsUrl}{GetQueryTypeUrl(queryType, queryParameter)}");

            case AnilistTypes.Character:
                return($"{CharacterUrl}{GetQueryTypeUrl(queryType, queryParameter)}");

            case AnilistTypes.Staff:
                return($"{StaffUrl}{GetQueryTypeUrl(queryType, queryParameter)}");

            case AnilistTypes.Studio:
                return($"{StudioUrl}{GetQueryTypeUrl(queryType, queryParameter)}");

            case AnilistTypes.BrowseAnime:
                return($"{BrowseUrl}anime{GetBrowseUrlParameteres(BrowseCriteriaDTO.CriterToCriteriaDTO((BrowseCriteria)queryParameter))}");

            case AnilistTypes.GenreList:
                return($"{GenreListUrl}");
            }

            return(null);
        }
Exemplo n.º 2
0
        private static string GetBrowseUrlParameteres(BrowseCriteriaDTO criteria)
        {
            var result = new StringBuilder("?");

            var properties = criteria.GetType().GetProperties();

            foreach (var property in properties)
            {
                if (property.GetValue(criteria, null) != null)
                {
                    result.Append($"{property.Name}={property.GetValue(criteria, null)}&");
                }
            }

            return($"{result.ToString().Substring(0, result.ToString().Length - 1)}");
        }