Explorar el Código

更新Enum扩展方法

HerobrineXia hace 2 meses
padre
commit
5a6dce8b96
Se han modificado 1 ficheros con 3 adiciones y 0 borrados
  1. 3 0
      Shared/Utils/EnumUtils.cs

+ 3 - 0
Shared/Utils/EnumUtils.cs

@@ -24,6 +24,9 @@ public static class EnumUtils {
         }
     }
 
+    public static bool HasFlagF<T>(this T value, T flag) where T : struct, Enum
+        => value.HasFlag(flag) && !EqualityComparer<T>.Default.Equals(flag, default);
+
     /// <summary>
     /// 对于具有 <see cref="FlagsAttribute"/> 的枚举,返回其所有 Flag 值。
     /// 建议仅对没有极端值的正数枚举使用。