I have a variety of C# enums, with some containing flags set. For instance:
[Flags]
public enum MyEnum
{
item1 = 0x0000,
item2 = 0x0008
}
To replicate this in JavaScript, I created something like the following:
my.namespace.MyEnum = {
ITEM1: "item1",
ITEM2: "item2"
}
I am utilizing a global WebApi converter to convert enums to strings for use with the REST API:
config.Formatters.JsonFormatter.SerializerSettings.Converters.Add(new StringEnumConverter());
The issue arises when trying to perform bitwise operations on properties using this enum (e.g. my.namespace.MyEnum.ITEM1 | my.namespace.MyEnum.ITEM2) to achieve the desired result ("item1, item2").
Is there a more appropriate method to implement this DataContract + JS API for flags enum in JavaScript, besides simply removing the string converter?