示例#1
0
        public static void Main(string[] args)
        {
            OrderBy1.QuerySyntaxExample();
            OrderBy1.MethodSyntaxExample();

            OrderBy2.QuerySyntaxExample();
            OrderBy2.MethodSyntaxExample();

            OrderBy3.QuerySyntaxExample();
            OrderBy3.MethodSyntaxExample();

            OrderByComparer1.MethodSyntaxExample();

            OrderByDescending1.QuerySyntaxExample();
            OrderByDescending1.MethodSyntaxExample();

            OrderByDescending2.QuerySyntaxExample();
            OrderByDescending2.MethodSyntaxExample();

            OrderByDescendingComparer1.MethodSyntaxExample();

            ThenBy1.QuerySyntaxExample();
            ThenBy1.MethodSyntaxExample();

            ThenByComparer1.MethodSyntaxExample();

            ThenByDescending1.QuerySyntaxExample();
            ThenByDescending1.MethodSyntaxExample();

            ThenByDescendingComparer1.MethodSyntaxExample();

            Reverse1.QuerySyntaxExample();
            Reverse1.MethodSyntaxExample();
        }
示例#2
0
        /// <summary>
        /// Create query from current parameters for search request.
        /// </summary>
        /// <returns>Query from current parameters for search request</returns>
        public string ConfigToString()
        {
            StringBuilder builder = new StringBuilder();

            if (!string.IsNullOrWhiteSpace(Query))
            {
                builder.Append($"q={Query}");
            }

            if (Page > 0)
            {
                builder.Append($"&page={Page}");
            }

            if (OrderBy != UserListAnimeSearchSortable.NoSorting)
            {
                Guard.IsValidEnum(OrderBy, nameof(OrderBy));
                Guard.IsValidEnum(SortDirection, nameof(SortDirection));
                builder.Append($"&order_by={OrderBy.GetDescription()}");
                builder.Append($"&sort={SortDirection.GetDescription()}");

                if (OrderBy2 != UserListAnimeSearchSortable.NoSorting)
                {
                    Guard.IsValidEnum(OrderBy2, nameof(OrderBy2));
                    builder.Append($"&order_by2={OrderBy2.GetDescription()}");
                }
            }

            if (ProducerId > 0)
            {
                builder.Append($"&producer={ProducerId}");
            }

            if (Year > 0)
            {
                Guard.IsValidEnum(Season, nameof(Season));
                builder.Append($"&year={Year}");
                builder.Append($"&season={Season.GetDescription()}");
            }

            if (AiringStatus != UserListAnimeAiringStatus.NoFilter)
            {
                Guard.IsValidEnum(AiringStatus, nameof(AiringStatus));
                builder.Append($"&airing_status={AiringStatus.GetDescription()}");
            }

            // change first ampersand into question mark
            return(string.Concat("?", builder.ToString().TrimEnd('&').TrimStart('&')));
        }
        /// <summary>
        /// Create query from current parameters for search request.
        /// </summary>
        /// <returns>Query from current parameters for search request</returns>
        public string ConfigToString()
        {
            StringBuilder builder = new StringBuilder();

            if (!string.IsNullOrWhiteSpace(Query))
            {
                builder.Append($"q={Query}");
            }

            if (Page > 0)
            {
                builder.Append($"&page={Page}");
            }

            if (OrderBy != UserListMangaSearchSortable.NoSorting)
            {
                builder.Append($"&order_by={OrderBy.GetDescription()}");
                builder.Append($"&sort={SortDirection.GetDescription()}");

                if (OrderBy2 != UserListMangaSearchSortable.NoSorting)
                {
                    builder.Append($"&order_by2={OrderBy2.GetDescription()}");
                }
            }

            if (MagazineId > 0)
            {
                builder.Append($"&magazine={MagazineId}");
            }

            if (PublishingStatus != UserListMangaPublishingStatus.NoFilter)
            {
                builder.Append($"&publishing_status={PublishingStatus.GetDescription()}");
            }

            // change first ampersand into question mark
            return(string.Concat("?", builder.ToString().TrimEnd('&').TrimStart('&')));
        }