Class StringEnum<T>
Helper class for working with 'extended' enums using StringValueAttribute attributes.
Inheritance
Inherited Members
Namespace: netDxf
Assembly: CADability.dll
Syntax
public class StringEnum<T>
Type Parameters
| Name | Description |
|---|---|
| T |
Constructors
| Improve this Doc View SourceStringEnum()
Creates a new StringEnum<T> instance.
Declaration
public StringEnum()
Properties
| Improve this Doc View SourceEnumType
Gets the underlying enum type for this instance.
Declaration
public Type EnumType { get; }
Property Value
| Type | Description |
|---|---|
| System.Type |
Methods
| Improve this Doc View SourceGetStringValue(T)
Gets a string value for a particular enum value.
Declaration
public static string GetStringValue(T value)
Parameters
| Type | Name | Description |
|---|---|---|
| T | value | Value. |
Returns
| Type | Description |
|---|---|
| System.String | String Value associated via a StringValueAttribute attribute, or null if not found. |
GetStringValues()
Gets the string values associated with the enum.
Declaration
public List<string> GetStringValues()
Returns
| Type | Description |
|---|---|
| System.Collections.Generic.List<System.String> | String value array |
GetValues()
Gets the enum entry and string value pairs.
Declaration
public Dictionary<T, string> GetValues()
Returns
| Type | Description |
|---|---|
| System.Collections.Generic.Dictionary<T, System.String> | A dictionary containing each enum entry with its corresponding string value. |
IsStringDefined(String)
Return the existence of the given string value within the enum.
Declaration
public static bool IsStringDefined(string value)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | value | String value. |
Returns
| Type | Description |
|---|---|
| System.Boolean | Existence of the string value |
IsStringDefined(String, StringComparison)
Return the existence of the given string value within the enum.
Declaration
public static bool IsStringDefined(string value, StringComparison comparisonType)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | value | String value. |
| System.StringComparison | comparisonType | Specifies how to conduct a case-insensitive match on the supplied string value |
Returns
| Type | Description |
|---|---|
| System.Boolean | Existence of the string value |
Parse(String)
Parses the supplied enum and string value to find an associated enum value.
Declaration
public static T Parse(string value)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | value | String value. |
Returns
| Type | Description |
|---|---|
| T | Enum value associated with the string value, if not found the default enum will be returned. |
Parse(String, StringComparison)
Parses the supplied enum and string value to find an associated enum value.
Declaration
public static T Parse(string value, StringComparison comparisonType)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | value | String value. |
| System.StringComparison | comparisonType | Specifies how to conduct a case-insensitive match on the supplied string value. |
Returns
| Type | Description |
|---|---|
| T | Enum value associated with the string value, if not found the default enum will be returned. |