Show / Hide Table of Contents

Class StringEnum<T>

Helper class for working with 'extended' enums using StringValueAttribute attributes.

Inheritance
System.Object
StringEnum<T>
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: netDxf
Assembly: CADability.dll
Syntax
public class StringEnum<T>
Type Parameters
Name Description
T

Constructors

| Improve this Doc View Source

StringEnum()

Creates a new StringEnum<T> instance.

Declaration
public StringEnum()

Properties

| Improve this Doc View Source

EnumType

Gets the underlying enum type for this instance.

Declaration
public Type EnumType { get; }
Property Value
Type Description
System.Type

Methods

| Improve this Doc View Source

GetStringValue(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.

| Improve this Doc View Source

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

| Improve this Doc View Source

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.

| Improve this Doc View Source

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

| Improve this Doc View Source

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

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

  • Improve this Doc
  • View Source
In This Article
Back to top Generated by DocFX