public static bool HasAnyFlag <TEnum>( this TEnum value, TEnum flag0, TEnum flag1) where TEnum : Enum { if (EnumExtensionsInternal <TEnum> .HasFlagsDelegate(value, flag0) || EnumExtensionsInternal <TEnum> .HasFlagsDelegate(value, flag1)) { return(true); } return(false); }
/// <summary> /// Determines whether the specified value has multiple flags. /// </summary> /// <typeparam name="TEnum">The type of the enum.</typeparam> /// <param name="value">The value.</param> /// <param name="flag">The flags.</param> /// <returns> /// <c>true</c> if the specified value has any flag; otherwise, <c>false</c>. /// </returns> public static bool HasAnyFlag <TEnum>(this TEnum value, params TEnum[] flags) where TEnum : Enum { for (int i = 0; i < flags.Length; i++) { if (EnumExtensionsInternal <TEnum> .HasFlagsDelegate(value, flags[i])) { return(true); } } return(false); }
public static bool HasFlags <TEnum>( this TEnum value, TEnum flag0, TEnum flag1, TEnum flag2, TEnum flag3, TEnum flag4, TEnum flag5) where TEnum : Enum { if (EnumExtensionsInternal <TEnum> .HasFlagsDelegate(value, flag0) || EnumExtensionsInternal <TEnum> .HasFlagsDelegate(value, flag1) || EnumExtensionsInternal <TEnum> .HasFlagsDelegate(value, flag2) || EnumExtensionsInternal <TEnum> .HasFlagsDelegate(value, flag3) || EnumExtensionsInternal <TEnum> .HasFlagsDelegate(value, flag4) || EnumExtensionsInternal <TEnum> .HasFlagsDelegate(value, flag5)) { return(true); } return(false); }
/// <summary> /// Determines whether the specified value has flags. /// </summary> /// <typeparam name="TEnum">The type of the enum.</typeparam> /// <param name="value">The value.</param> /// <param name="flag">The flag.</param> /// <returns> /// <c>true</c> if the specified value has flags; otherwise, <c>false</c>. /// </returns> public static bool HasAnyFlag <TEnum>(this TEnum value, TEnum flag) where TEnum : Enum { return(EnumExtensionsInternal <TEnum> .HasFlagsDelegate(value, flag)); }
/// <summary> /// Determines whether the specified value has flags. Note this method is up to 60 times faster /// than the one that comes with .NET 4 as it avoids any explict boxing or unboxing. /// </summary> /// <typeparam name="TEnum">The type of the enum.</typeparam> /// <param name="value">The value.</param> /// <param name="flag">The flag.</param> /// <returns> /// <c>true</c> if the specified value has flags; otherwise, <c>false</c>. /// </returns> /// <exception cref="ArgumentException">If TEnum is not an enum.</exception> public static bool HasFlags <TEnum>(this TEnum value, TEnum flag) where TEnum : struct, IComparable, IConvertible, IFormattable { return(EnumExtensionsInternal <TEnum> .HasFlagsDelegate(value, flag)); }