I have many C# enums, and some of them have flags enabled. For example:
[Flags]
public enum MyEnum
{
item1 = 0x0000,
item2 = 0x0008
}
I cloned this into JavaScript with something like this:
my.namespace.MyEnum = {
ITEM1: "item1",
ITEM2: "item2"
}
I am using a global WebApi converter to map enums to string, because I prefer to use the strings with the REST API:
config.Formatters.JsonFormatter.SerializerSettings.Converters.Add(new StringEnumConverter());
The problem is that if I create a property that uses this enum, it can't use the bitwise operations (i.e. my.namespace.MyEnum.ITEM1 | my.namespace.MyEnum.ITEM2) and get the desired result ("item1, item2").
Aside from removing the string converter, is there any proper way to implement this kind of DataContract + JS API for flags enum in JavaScript?