예제 #1
0
        public IEnumerable <Game> GetGames(
            string seriesId,
            string name           = null, int?yearOfRelease   = null,
            string platformId     = null, string regionId     = null,
            string moderatorId    = null, int?elementsPerPage = null,
            GameEmbeds embeds     = default(GameEmbeds),
            GamesOrdering orderBy = default(GamesOrdering))
        {
            var parameters = new List <string>()
            {
                embeds.ToString()
            };

            parameters.AddRange(orderBy.ToParameters());

            if (!string.IsNullOrEmpty(name))
            {
                parameters.Add(string.Format("name={0}", Uri.EscapeDataString(name)));
            }

            if (yearOfRelease.HasValue)
            {
                parameters.Add(string.Format("released={0}", yearOfRelease.Value));
            }

            if (!string.IsNullOrEmpty(platformId))
            {
                parameters.Add(string.Format("platform={0}", Uri.EscapeDataString(platformId)));
            }

            if (!string.IsNullOrEmpty(regionId))
            {
                parameters.Add(string.Format("region={0}", Uri.EscapeDataString(regionId)));
            }

            if (!string.IsNullOrEmpty(moderatorId))
            {
                parameters.Add(string.Format("moderator={0}", Uri.EscapeDataString(moderatorId)));
            }

            if (elementsPerPage.HasValue)
            {
                parameters.Add(string.Format("max={0}", elementsPerPage.Value));
            }

            var uri = GetSeriesUri(string.Format("/{0}/games{1}",
                                                 Uri.EscapeDataString(seriesId),
                                                 parameters.ToParameters()));

            return(baseClient.DoPaginatedRequest(uri,
                                                 x => Game.Parse(baseClient, x) as Game));
        }
예제 #2
0
        public IEnumerable<GameHeader> GetGameHeaders(int elementsPerPage = 1000,
            GamesOrdering orderBy = default(GamesOrdering))
        {
            var parameters = new List<string>() { "_bulk=yes" };

            parameters.AddRange(orderBy.ToParameters());
            parameters.Add(string.Format("max={0}", elementsPerPage));

            var uri = GetGamesUri(parameters.ToParameters());

            return baseClient.DoPaginatedRequest(uri,
                x => GameHeader.Parse(baseClient, x) as GameHeader);
        }
예제 #3
0
        public IEnumerable <GameHeader> GetGameHeaders(int elementsPerPage = 1000, GamesOrdering orderBy = default)
        {
            var parameters = new List <string>()
            {
                "_bulk=yes"
            };

            parameters.AddRange(orderBy.ToParameters());
            parameters.Add(string.Format("max={0}", elementsPerPage));

            var uri = GetGamesUri(parameters.ToParameters());

            return(baseClient.DoPaginatedRequest(uri, x => GameHeader.Parse(baseClient, x) as GameHeader));
        }
예제 #4
0
        public ReadOnlyCollection <Game> GetRomHacks(string gameId,
                                                     GameEmbeds embeds     = default(GameEmbeds),
                                                     GamesOrdering orderBy = default(GamesOrdering))
        {
            var parameters = new List <string>()
            {
                embeds.ToString()
            };

            parameters.AddRange(orderBy.ToParameters());

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

            return(baseClient.DoDataCollectionRequest(uri,
                                                      x => Game.Parse(baseClient, x) as Game));
        }
예제 #5
0
        internal static IEnumerable <string> ToParameters(this GamesOrdering ordering)
        {
            var isDescending = ((int)ordering & 1) == 1;

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

            var str = "";

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

            case GamesOrdering.JapaneseName:
                str = "name.jap"; break;

            case GamesOrdering.Abbreviation:
                str = "abbreviation"; break;

            case GamesOrdering.YearOfRelease:
                str = "released"; break;

            case GamesOrdering.CreationDate:
                str = "created"; 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);
        }
예제 #6
0
        public IEnumerable<Game> GetGames(
            string seriesId,
            string name = null, int? yearOfRelease = null,
            string platformId = null, string regionId = null,
            string moderatorId = null, int? elementsPerPage = null,
            GameEmbeds embeds = default(GameEmbeds),
            GamesOrdering orderBy = default(GamesOrdering))
        {
            var parameters = new List<string>() { embeds.ToString() };

            parameters.AddRange(orderBy.ToParameters());

            if (!string.IsNullOrEmpty(name))
                parameters.Add(string.Format("name={0}", Uri.EscapeDataString(name)));

            if (yearOfRelease.HasValue)
                parameters.Add(string.Format("released={0}", yearOfRelease.Value));

            if (!string.IsNullOrEmpty(platformId))
                parameters.Add(string.Format("platform={0}", Uri.EscapeDataString(platformId)));

            if (!string.IsNullOrEmpty(regionId))
                parameters.Add(string.Format("region={0}", Uri.EscapeDataString(regionId)));

            if (!string.IsNullOrEmpty(moderatorId))
                parameters.Add(string.Format("moderator={0}", Uri.EscapeDataString(moderatorId)));

            if (elementsPerPage.HasValue)
                parameters.Add(string.Format("max={0}", elementsPerPage.Value));

            var uri = GetSeriesUri(string.Format("/{0}/games{1}",
                Uri.EscapeDataString(seriesId),
                parameters.ToParameters()));

            return baseClient.DoPaginatedRequest(uri,
                x => Game.Parse(baseClient, x) as Game);
        }
예제 #7
0
        public ReadOnlyCollection<Game> GetRomHacks(string gameId,
            GameEmbeds embeds = default(GameEmbeds),
            GamesOrdering orderBy = default(GamesOrdering))
        {
            var parameters = new List<string>() { embeds.ToString() };

            parameters.AddRange(orderBy.ToParameters());

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

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