Exemple #1
0
        public static TDestType SafeCast <TDestType>(this Enum s1)
        {
            AssertEnumType <TDestType>();

            var newValue = s1.ParseAs <TDestType>();

            if (newValue.AsInt() != s1.AsInt())
            {
                throw new InvalidCastException("This enum's name match... but their values do not.");
            }

            return(newValue);
        }
Exemple #2
0
 public static bool BitwiseHasFlag(this Enum flag, int value)
 {
     return((flag.AsInt() & value) == value);
 }