using System; namespace Umbraco.Core { /// /// Provides extension methods to . /// public static class EnumExtensions { /// /// Determines whether all the flags/bits are set within the enum value. /// /// The enum type. /// The enum value. /// The flags. /// /// true if all the flags/bits are set within the enum value; otherwise, false. /// [Obsolete("Use Enum.HasFlag() or bitwise operations (if performance is important) instead.")] public static bool HasFlagAll(this T value, T flags) where T : Enum { return value.HasFlag(flags); } /// /// Determines whether any of the flags/bits are set within the enum value. /// /// The enum type. /// The value. /// The flags. /// /// true if any of the flags/bits are set within the enum value; otherwise, false. /// public static bool HasFlagAny(this T value, T flags) where T : Enum { var v = Convert.ToUInt64(value); var f = Convert.ToUInt64(flags); return (v & f) > 0; } } }