示例#1
0
        public static IEnumerable <SimilarBoardGame> GetSimilarBoardGameList(string name)
        {
            var    url = string.Format(Constants.getXMLBoardGameObjectListByName, name);
            var    BGGBoardGameObjectStr = GetStringResponse(url);
            object boardGamesObject      = new boardgames();

            var xmlSerializer = new XmlSerializer(typeof(boardgames));

            using (TextReader textReader = new StringReader(BGGBoardGameObjectStr))
            {
                boardGamesObject = xmlSerializer.Deserialize(textReader);
            }

            var boardGames = (boardgames)boardGamesObject;

            if (boardGames.boardgame != null && boardGames.boardgame.Length > 0)
            {
                return(boardGames.boardgame.Select(x => new SimilarBoardGame
                {
                    Id = (int)x.objectid,
                    Name = x.name.Value
                }).ToList());
            }

            return(null);
        }
示例#2
0
        public static int GetBoardGameId(string name)
        {
            var objectId = 0;

            var    url           = string.Format(Constants.getXMLBoardGameObjectByName, name);
            var    BGGBoardGame  = GetStringResponse(url);
            object boardGamesObj = new boardgames();

            var xmlSerializer = new XmlSerializer(typeof(boardgames));

            using (TextReader textReader = new StringReader(BGGBoardGame))
            {
                boardGamesObj = xmlSerializer.Deserialize(textReader);
            }

            var boardGames = (boardgames)boardGamesObj;

            if (boardGames.boardgame != null && boardGames.boardgame.Length > 0)
            {
                objectId = (int)boardGames.boardgame.First().objectid;
            }

            return(objectId);
        }