According to
EnumMemberAttribute Class[
^], this attribute is defined as:
[AttributeUsage(AttributeTargets.Field, AllowMultiple=false, Inherited=false)]
public sealed class EnumMemberAttribute : Attribute
This means that you cannot match several names to the same enumeration value.
What you can do is provide a method which will return a
PrimaryColour
value from a string:
public static PrimaryColour GetColour(string value)
{
switch (value.ToLowerInvariant())
{
case "crimson":
case "scarlet":
return PrimaryColour.Red;
case "teal":
case "lime":
return PrimaryColour.Green;
default:
return PrimaryColour.Black;
}
}
Then, during the deserialization process, hook it to assign a correct value from json (this part depends on the way the json deserialization is handled, which I have no knowledge of at the moment).
Hope this helps.