Exemplo n.º 1
0
        internal static IEnumerable <string> ToParameters(this CategoriesOrdering ordering)
        {
            var isDescending = ((int)ordering & 1) == 1;

            if (isDescending)
            {
                ordering = (CategoriesOrdering)((int)ordering - 1);
            }

            var str = "";

            switch (ordering)
            {
            case CategoriesOrdering.Name:
                str = "name"; break;

            case CategoriesOrdering.Miscellaneous:
                str = "miscellaneous"; break;
            }

            var list = new List <string>();

            if (!string.IsNullOrEmpty(str))
            {
                list.Add(string.Format("orderby={0}", str));
            }
            if (isDescending)
            {
                list.Add("direction=desc");
            }

            return(list);
        }
Exemplo n.º 2
0
        public ReadOnlyCollection<Category> GetCategories(
            string levelId, bool miscellaneous = true,
            CategoryEmbeds embeds = default(CategoryEmbeds),
            CategoriesOrdering orderBy = default(CategoriesOrdering))
        {
            var parameters = new List<string>() { embeds.ToString() };

            parameters.AddRange(orderBy.ToParameters());

            if (!miscellaneous)
                parameters.Add("miscellaneous=no");

            var uri = GetLevelsUri(string.Format("/{0}/categories{1}",
                Uri.EscapeDataString(levelId),
                parameters.ToParameters()));

            return baseClient.DoDataCollectionRequest<Category>(uri,
                x => Category.Parse(baseClient, x));
        }
Exemplo n.º 3
0
        public ReadOnlyCollection <Category> GetCategories(
            string gameId, bool miscellaneous = true,
            CategoryEmbeds embeds             = default(CategoryEmbeds),
            CategoriesOrdering orderBy        = default(CategoriesOrdering))
        {
            var parameters = new List <string>()
            {
                embeds.ToString()
            };

            parameters.AddRange(orderBy.ToParameters());

            if (!miscellaneous)
            {
                parameters.Add("miscellaneous=no");
            }

            var uri = GetGamesUri(string.Format("/{0}/categories{1}",
                                                Uri.EscapeDataString(gameId),
                                                parameters.ToParameters()));

            return(baseClient.DoDataCollectionRequest(uri,
                                                      x => Category.Parse(baseClient, x) as Category));
        }