Beispiel #1
0
        /// <summary>
        /// Creates a PokeApiType from a JSON source
        /// </summary>
        /// <param name="source">The JSON source</param>
        /// <param name="ret">An object that inherits from PokeApiType</param>
        public static void Create(JsonData source, ref PokeApiType ret)
        {
            if (source.Keys.Contains("error_message"))
                throw new PokemonParseException(source["error_message"].ToString());

            if (!ret.OverrideDefaultParsing())
            {
                ret.name = source["name"].ToString().Replace('-', ' ');
                ret.uri = new Uri("http://www.pokeapi.co/" + source["resource_uri"].ToString());
                if (source.Keys.Contains("id")) // pokemon uses national_id, and the dex can't have an ID
                    ret.id = (int)source["id"];
                ret.created = ParseDateString(source["created"].ToString());
                ret.modified = ParseDateString(source["created"].ToString());
            }

            ret.Create(source);
        }
Beispiel #2
0
        /// <summary>
        /// Creates a PokeApiType from a JSON source
        /// </summary>
        /// <param name="source">The JSON source</param>
        /// <param name="ret">An object that inherits from PokeApiType</param>
        /// <returns>ret with the data from the JSON source</returns>
        public static PokeApiType Create(JsonData source, PokeApiType ret)
        {
            Create(source, ref ret);

            return ret;
        }