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}"); }
public override bool CanConvert(Type typeToConvert) => typeToConvert.IsEnum && !FlagEnums.IsFlagEnum(typeToConvert) && Enums.GetNames(typeToConvert).Any(name => name.Any(c => char.IsLower(c))) ;
public void IsFlagEnum_Test() { Assert.IsTrue(FlagEnums.IsFlagEnum <ColorFlagEnum>()); Assert.IsFalse(FlagEnums.IsFlagEnum <NonContiguousEnum>()); }