Пример #1
0
        private static object GetEnums(this Type enumType, object value)
        {
            if (FlagEnums.IsFlagEnum(enumType) && FlagEnums.HasAnyFlags(enumType, value))
            {
                return(string.Join("|", FlagEnums.GetFlagMembers(enumType, value)
                                   .Select(member => $"{enumType.FullName}.{member.Name}")));
            }

            var name = Enum.GetName(enumType, value);

            return($"{enumType.FullName}.{name}");
        }
Пример #2
0
 public override bool CanConvert(Type typeToConvert) =>
 typeToConvert.IsEnum &&
 !FlagEnums.IsFlagEnum(typeToConvert) &&
 Enums.GetNames(typeToConvert).Any(name => name.Any(c => char.IsLower(c)))
 ;
Пример #3
0
 public void IsFlagEnum_Test()
 {
     Assert.IsTrue(FlagEnums.IsFlagEnum <ColorFlagEnum>());
     Assert.IsFalse(FlagEnums.IsFlagEnum <NonContiguousEnum>());
 }