Esempio n. 1
0
 /// <summary>
 /// Determines whether all of the flags in <paramref name="desiredFlags"/>
 /// </summary>
 /// <param name="value">Value to test</param>
 /// <param name="desiredFlags">Flags we wish to find</param>
 /// <returns>Whether all the flags in <paramref name="desiredFlags"/> are in <paramref name="value"/>.</returns>
 /// <exception cref="TypeArgumentException"><typeparamref name="T"/> is not a flags enum.</exception>
 public static bool HasAll <T>(this T value, T desiredFlags) where T : struct, IEnumConstraint
 {
     ThrowIfNotFlags <T>();
     return(EnumInternals <T> .Equality(value.And(desiredFlags), desiredFlags));
 }
Esempio n. 2
0
 /// <summary>
 /// Returns the inverse of a value, with no consideration for which bits are used
 /// by values within the enum (i.e. a simple bitwise negation).
 /// </summary>
 /// <typeparam name="T">Enum type</typeparam>
 /// <param name="value">Value to invert</param>
 /// <returns>The bitwise negation of the value</returns>
 /// <exception cref="TypeArgumentException"><typeparamref name="T"/> is not a flags enum.</exception>
 public static T AllBitsInverse <T>(this T value) where T : struct, IEnumConstraint
 {
     ThrowIfNotFlags <T>();
     return(EnumInternals <T> .Not(value));
 }
Esempio n. 3
0
 /// <summary>
 /// Returns whether this value is an empty set of fields, i.e. the zero value.
 /// </summary>
 /// <typeparam name="T">Enum type</typeparam>
 /// <param name="value">Value to test</param>
 /// <returns>True if the value is empty (zero); False otherwise.</returns>
 /// <exception cref="TypeArgumentException"><typeparamref name="T"/> is not a flags enum.</exception>
 public static bool IsEmpty <T>(this T value) where T : struct, IEnumConstraint
 {
     ThrowIfNotFlags <T>();
     return(EnumInternals <T> .IsEmpty(value));
 }
Esempio n. 4
0
 /// <summary>
 /// Returns the bitwise "or" of two values.
 /// </summary>
 /// internal static
 /// <param name="first">First value</param>
 /// <param name="second">Second value</param>
 /// <returns>The bitwise "or" of the two values</returns>
 /// <exception cref="TypeArgumentException"><typeparamref name="T"/> is not a flags enum.</exception>
 public static T Or <T>(this T first, T second) where T : struct, IEnumConstraint
 {
     ThrowIfNotFlags <T>();
     return(EnumInternals <T> .Or(first, second));
 }