/// <summary> /// Cast <see cref="object"/> to the TEnum. /// </summary> /// <param name="fromObj"></param> /// <param name="validation"></param> /// <typeparam name="TObject"></typeparam> /// <typeparam name="TEnum"></typeparam> /// <returns></returns> public static TEnum CastTo <TObject, TEnum>(TObject fromObj, EnumsNET.EnumValidation validation) where TEnum : struct, Enum => EnumsNET.Enums.ToObject <TEnum>(fromObj, validation);
/// <summary> /// Cast <see cref="object"/> to the given type of <see cref="Enum"/>. /// </summary> /// <param name="fromObj"></param> /// <param name="enumTye"></param> /// <param name="validation"></param> /// <returns></returns> public static object CastTo(object fromObj, Type enumTye, EnumsNET.EnumValidation validation) { CastTypeHelper.Guard(enumTye, nameof(enumTye)); return(EnumsNET.Enums.ToObject(enumTye, fromObj, validation)); }
/// <summary> /// Cast <see cref="object"/> to the given type of <see cref="Enum"/>. /// </summary> /// <param name="fromObj"></param> /// <param name="enumTye"></param> /// <param name="validation"></param> /// <returns></returns> public static object CastTo(object fromObj, Type enumTye, EnumsNET.EnumValidation validation) => EnumsNET.Enums.ToObject(enumTye, fromObj, validation);
/// <summary> /// Cast <see cref="object"/> to the TEnum. /// </summary> /// <param name="fromObj"></param> /// <param name="validation"></param> /// <typeparam name="TObject"></typeparam> /// <typeparam name="TEnum"></typeparam> /// <returns></returns> public static TEnum CastTo <TObject, TEnum>(TObject fromObj, EnumsNET.EnumValidation validation) where TEnum : struct, Enum { return(fromObj is null ? default : EnumsNET.Enums.ToObject <TEnum>(fromObj, validation)); }