Ejemplo n.º 1
0
 public T GetEnum <T>(string name, T fallback) where T : struct
 {
     return(SocialUtils.ParseEnum <T>(GetString(name), fallback));
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Gets an enum of type <code>T</code> from the property with the specified <code>propertyName</code>.
        /// </summary>
        /// <typeparam name="T">The type of the enum.</typeparam>
        /// <param name="obj">The instance of <code>JObject</code>.</param>
        /// <param name="propertyName">The name of the property.</param>
        /// <param name="fallback">The fallback value if the value in the JSON couldn't be parsed.</param>
        public static T GetEnum <T>(this Newtonsoft.Json.Linq.JObject obj, string propertyName, T fallback) where T : struct
        {
            string value = GetString(obj, propertyName);

            return(String.IsNullOrWhiteSpace(value) ? fallback : SocialUtils.ParseEnum(value, fallback));
        }
Ejemplo n.º 3
0
 public T GetEnum <T>(string name) where T : struct
 {
     return(SocialUtils.ParseEnum <T>(GetString(name)));
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Gets an enum of type <code>T</code> from the property with the specified <code>propertyName</code>.
 /// </summary>
 /// <typeparam name="T">The type of the enum.</typeparam>
 /// <param name="obj">The instance of <code>JObject</code>.</param>
 /// <param name="propertyName">The name of the property.</param>
 public static T GetEnum <T>(this Newtonsoft.Json.Linq.JObject obj, string propertyName) where T : struct
 {
     return(SocialUtils.ParseEnum <T>(GetString(obj, propertyName)));
 }