Programming

Select List Enum Tag Helper

Select list enum tag helper. If you want to have a select list in a web page which is based on all the values in an enum then you can use the built in function “Html.GetEnumSelectList” with a tag helper. public enum PushType { Notification, Image, Action } <div class="row"> Read more…

By Shinigami, ago
Programming

Enum JSON Converter

Enum JSON converter. In addition to the SingleOrArrayEnumConverter mentioned previously I’ve also created a version to translate enums to/from JSON using the name of the enum rather than it’s value as is the default. class EnumConverter<T> : JsonConverter { public override bool CanConvert(Type objectType) { return (objectType == typeof(T)); } Read more…

By Shinigami, ago
Programming

Single or Array Enum JSON Converter

Single or array enum JSON converter. In addition to the SingleOrArrayConverter mentioned previously I’ve also created a version to translate enums to/from JSON using the name of the enum rather than it’s value as is the default. public class SingleOrArrayEnumConverter<T> : JsonConverter { public override bool CanConvert(Type objectType) { return Read more…

By Shinigami, ago