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); }
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)); }
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); }