Skip to main content

Class StringEnumeration

A Smart Enumeration class that includes additional 'Batteries' to enhance a standard enumeration. References: https://lostechies.com/jimmybogard/2008/08/12/enumeration-classes/

Namespace: Workspace.XBR.Xperiflow.Utilities.Text

Assembly: Xperiflow.dll

Declaration
[JsonConverter(typeof(StringEnumerationConverter))]
public abstract class StringEnumeration : IComparable

Derived:

Expand

Implements: System.IComparable

Properties​

Value​

Declaration
public int Value { get; }

DisplayName​

Declaration
public string DisplayName { get; }

Methods​

ToString()​

Returns a string that represents the current object.

Declaration
public override string ToString()
Returns​

System.String

A string that represents the current object.

Equals(object)​

Determines whether the specified object is equal to the current object.

Declaration
public override bool Equals(object obj)
Returns​

System.Boolean

true if the specified object is equal to the current object; otherwise, false.

Parameters​
TypeNameDescription
System.ObjectobjThe object to compare with the current object.

GetHashCode()​

Serves as the default hash function.

Declaration
public override int GetHashCode()
Returns​

System.Int32

A hash code for the current object.

GetAll<T>()​

Provides an iterator to iterate over all StringEnumeration constants.

Declaration
public static IEnumerable<T> GetAll<T>() where T : StringEnumeration, new()
Returns​

System.Collections.Generic.IEnumerable<{T}>

Type Parameters​
  • T

AbsoluteDifference(StringEnumeration, StringEnumeration)​

Declaration
public static int AbsoluteDifference(StringEnumeration firstValue, StringEnumeration secondValue)
Returns​

System.Int32

Parameters​
TypeName
Workspace.XBR.Xperiflow.Utilities.Text.StringEnumerationfirstValue
Workspace.XBR.Xperiflow.Utilities.Text.StringEnumerationsecondValue

FromValue<T>(int)​

Creates a StringEnumeration Type from an expected value.

Declaration
public static T FromValue<T>(int value) where T : StringEnumeration, new()
Returns​

<T>

Parameters​
TypeName
System.Int32value
Type Parameters​
  • T

FromDisplayName<T>(string)​

Creates a StringEnumeration Type from an expected display name.

Declaration
public static T FromDisplayName<T>(string displayName) where T : StringEnumeration, new()
Returns​

<T>

Parameters​
TypeName
System.StringdisplayName
Type Parameters​
  • T

Contains<T>(T)​

Determines if the specified value is contained within the set of StringEnumeration constants.

Declaration
public static bool Contains<T>(T value) where T : StringEnumeration, new()
Returns​

System.Boolean

Parameters​
TypeName
<T>value
Type Parameters​
  • T

DisplayNames<T>()​

Retrieves all display names for the StringEnumeration constants.

Declaration
public static List<string> DisplayNames<T>() where T : StringEnumeration, new()
Returns​

System.Collections.Generic.List<System.String>

List of display names.

Type Parameters​
NameDescription
TType of StringEnumeration.

HasDisplayName<T>(string)​

Checks if the given display name exists in the set of StringEnumeration constants.

Declaration
public static bool HasDisplayName<T>(string displayName) where T : StringEnumeration, new()
Returns​

System.Boolean

True if the display name exists, otherwise false.

Parameters​
TypeNameDescription
System.StringdisplayNameDisplay name to check.
Type Parameters​
NameDescription
TType of StringEnumeration.

ToDataTable<T>()​

Converts the String Enumeration options to a DataTable Example: Dim myDataTable = StringEnumeration.ToDataTable(Of ConcreteStringEnum)()

Declaration
public static DataTable ToDataTable<T>() where T : StringEnumeration, new()
Returns​

System.Data.DataTable

Type Parameters​
  • T

CompareTo(object)​

Compares the current instance with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other object.

Declaration
public int CompareTo(object obj)
Returns​

System.Int32

A value that indicates the relative order of the objects being compared. The return value has these meanings:

Value Meaning Less than zero This instance precedes obj in the sort order. Zero This instance occurs in the same position in the sort order as obj. Greater than zero This instance follows obj in the sort order.

Parameters​
TypeNameDescription
System.ObjectobjAn object to compare with this instance.
Exceptions​

System.ArgumentException obj is not the same type as this instance.

Implements​

  • System.IComparable

Inherited Members​

  • System.Object.Equals(System.Object,System.Object)
  • System.Object.GetType
  • System.Object.MemberwiseClone
  • System.Object.ReferenceEquals(System.Object,System.Object)

Was this page helpful?