Skip to content

StringEnum class

namespace: Serenity   assembly: Serenity.Net.Core

Base class for string enumerations, which are classes having public constant string fields as their members, an alternative to numeric enums for sets of values that are stored and sent to the client as strings. Only the members declared on the type are part of its set, which is what the server typings generator emits.

public abstract class StringEnum

Public Members

name description
static GetInfo(…) Gets the cached information for a string enumeration type.
static GetInfo<TStringEnum>() Gets the cached information for a string enumeration type.
static GetName(…) Gets the name of the member with the given value.
static GetName<TStringEnum>(…) Gets the name of the member with the given value.
static GetNames(…) Gets the names of all the members in their declaration order, including the members hidden from the client.
static GetNames<TStringEnum>() Gets the names of all the members in their declaration order, including the members hidden from the client.
static GetText(…) Gets the display text of the member with the given value, using the Enums.<EnumKey>.<Name> local text key, like a numeric enum.
static GetText<TStringEnum>(…) Gets the display text of the member with the given value, using the Enums.<EnumKey>.<Name> local text key, like a numeric enum.
static GetValue(…) Gets the string value of the member with the given name.
static GetValue<TStringEnum>(…) Gets the string value of the member with the given name.
static GetValues(…) Gets the string values of all the members in their declaration order, including the members hidden from the client. Like Type), which knows every member of an enum.
static GetValues<TStringEnum>() Gets the string values of all the members in their declaration order, including the members hidden from the client.
static IsDefined(…) Gets whether the given value is one of the members of the string enumeration.
static IsDefined<TStringEnum>(…) Gets whether the given value is one of the members of the string enumeration.
static IsStringEnum(…) Gets whether the given type is a string enumeration type.

Protected Members

name description
StringEnum() The default constructor.

Examples

[EnumKey("MyApp.WidgetCategory")]
public abstract class WidgetCategory : StringEnum
{
    [Description("Charts")]
    public const string Charts = "charts";
    public const string Tables = "tables";
}

See Also