Пример #1
0
        /// <summary>
        /// Requests a list of properties from API for a given film entity and attempts to obtain the specified property of the entity
        /// </summary>
        /// <param name="filmPropName"></param>
        /// <param name="propName"></param>
        /// <param name="propUrl"></param>
        /// <returns>The property requested, if applicable</returns>
        public string GetEntityProperty(string filmEntityName, string propName, string propUrl)
        {
            string returnValue = "";

            switch (filmEntityName)
            {
            case "starships":
                Starship star = core.GetStarshipByURL(propUrl);
                if (ErrorHandler.HasProperty(star, propName))
                {
                    returnValue = star.GetType().GetProperty(propName).GetValue(star, null).ToString();
                }

                break;

            case "planets":
                Planet planet = core.GetPlanetByURL(propUrl);
                if (ErrorHandler.HasProperty(planet, propName))
                {
                    returnValue = planet.GetType().GetProperty(propName).GetValue(planet, null).ToString();
                }
                break;

            case "characters":
                People people = core.GetPeopleByURL(propUrl);
                if (ErrorHandler.HasProperty(people, propName))
                {
                    returnValue = people.GetType().GetProperty(propName).GetValue(people, null).ToString();
                }
                break;
            }

            return(returnValue);
        }