Exemple #1
0
        /// <summary>
        /// Converts an enum with flags into a list of enums.
        /// </summary>
        public static IEnumerable <TEnum> ToList <TEnum>(this System.Enum type)
        {
            IEnumerable <TEnum> allMembers = EnumUtility.GetMembers <TEnum>();
            List <TEnum>        outList    = new List <TEnum>();

            foreach (TEnum member in allMembers)
            {
                if (type.Contains(member))
                {
                    outList.Add(member);
                }
            }
            return(outList);
        }
Exemple #2
0
 /// <summary>
 /// 校验某个枚举组合值里是否包含特定的枚举
 /// </summary>
 /// <param name="combinedEnum">结合的枚举</param>
 /// <param name="enums">要判断的枚举值</param>
 /// <returns>是否包含指定的枚举值</returns>
 public static bool Contains(this System.Enum combinedEnum, params System.Enum[] enums)
 {
     return(combinedEnum.Contains(true, enums));
 }