Пример #1
0
        public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
        {
            if (reader.Value == null)
            {
                return(null);
            }

            var enumString = reader.Value as string;

            if (string.IsNullOrEmpty(enumString))
            {
                return(Activator.CreateInstance(typeof(T)));
            }

            return(TraktEnumeration.FromObjectName <T>(enumString));
        }
Пример #2
0
 /// <summary>Calculates the absolute difference of the <see cref="Value" /> for two enumerations.</summary>
 /// <param name="first">The first enumeration.</param>
 /// <param name="second">The second enumeration.</param>
 /// <returns>The absolute difference of the <see cref="Value" /> for two enumerations.</returns>
 public static int AbsoluteDifference(TraktEnumeration first, TraktEnumeration second) => Math.Abs(first.Value - second.Value);