In my C# backend, I have enumerated settings with unique numbers assigned to each.
public enum Settings
{
Setting1 = 1,
Setting2 = 2,
//...
}
To send these settings to the client through WebAPI, I use a dictionary structure.
public MyModel
{
public Dictionary<Settings, string> MySettings { get; set; }
//...other properties...
}
The issue arises when referencing this Enum in TypeScript. The problem lies in WebAPI converting the enum values to strings instead of numbers. However, I want to maintain the type of the dictionary as
Dictionary<Settings, string>
and not switch it to Dictionary<int, string>
.
Is there a way to achieve this using attributes?