예제 #1
0
        internal static IEnumerable <string> ToParameters(this LevelsOrdering ordering)
        {
            var isDescending = ((int)ordering & 1) == 1;

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

            var str = "";

            switch (ordering)
            {
            case LevelsOrdering.Name:
                str = "name"; 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);
        }
예제 #2
0
        public ReadOnlyCollection <Level> GetLevels(string gameId,
                                                    LevelEmbeds embeds     = default(LevelEmbeds),
                                                    LevelsOrdering orderBy = default(LevelsOrdering))
        {
            var parameters = new List <string>()
            {
                embeds.ToString()
            };

            parameters.AddRange(orderBy.ToParameters());

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

            return(baseClient.DoDataCollectionRequest(uri,
                                                      x => Level.Parse(baseClient, x) as Level));
        }
예제 #3
0
        public ReadOnlyCollection<Level> GetLevels(string gameId,
            LevelEmbeds embeds = default(LevelEmbeds),
            LevelsOrdering orderBy = default(LevelsOrdering))
        {
            var parameters = new List<string>() { embeds.ToString() };

            parameters.AddRange(orderBy.ToParameters());

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

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