Esempio n. 1
0
 public T GetEnum <T>(string name, T fallback) where T : struct
 {
     return(SocialUtils.ParseEnum <T>(GetString(name), fallback));
 }
Esempio 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));
        }
Esempio n. 3
0
 public T GetEnum <T>(string name) where T : struct
 {
     return(SocialUtils.ParseEnum <T>(GetString(name)));
 }
Esempio 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)));
 }