Reinforced.Typings
Reinforced.Typings copied to clipboard
Export public static properties of static class to enum
Hi,
Is it possible to convert this
MyStaticClass.cs
public static class MyStaticClass
{
public static readonly string Property1 = "Property1";
public static readonly string Property2 = "Property2";
}
to
myEnums.ts
export enum MyStaticClass
{
Property1 = "Property1",
Property2 = "Property2",
}
?
Thank you!
Instead of using a C# class use a C# enum with the TsEnum UseString option.
[TsEnum(UseString = true)]
public enum MyEnum
{
Property1,
Property2
}
This will generate your desired TypeScript enum. To access the string equivilant of the enum in C# simply use the ToString funciton.
MyEnum.Property1.ToString()
Is there a way to allow more flexibility in naming conventions for enums? What if I have property value such as "x-my-http-header"?