Show / Hide Table of Contents

Class EnumUtilities

Contains many utility functions for enums

Inheritance
object
EnumUtilities
Namespace: WeaverCore.Utilities
Assembly: WeaverCore.dll
Syntax
public static class EnumUtilities

Methods

| Edit this page View Source

GetAllEnumValues<T>()

Returns an Enumerable for all the enum values in an enum type

Declaration
public static IEnumerable<T> GetAllEnumValues<T>()
Returns
Type Description
IEnumerable<T>

Returns an Enumerable for all the enum values in an enum type

Type Parameters
Name Description
T

The enum type to get the list from

Exceptions
Type Condition
Exception

Throws if the enum type isn't an enum

| Edit this page View Source

RandomEnumValue<EnumType>(params EnumType[])

Randomly selects a random enum value

Declaration
public static EnumType RandomEnumValue<EnumType>(params EnumType[] excludedValues)
Parameters
Type Name Description
EnumType[] excludedValues

Any values that are excluded from the randomizer

Returns
Type Description
EnumType
Type Parameters
Name Description
EnumType

The type of enum to randomly select from

Exceptions
Type Condition
Exception

Throws if EnumType is not an Enum

ArgumentException

Throws if all values are excluded from the randomizer, preventing a single value from being selected

InvalidEnumArgumentException

Throws if the enum has no values to select from

| Edit this page View Source

RawConvert(object, Type)

Forcefully converts from one enum to another

Declaration
public static object RawConvert(object source, Type destEnumType)
Parameters
Type Name Description
object source

The enum value to convert

Type destEnumType

The destination enum type

Returns
Type Description
object

Returns the forcefully converted enum value

Exceptions
Type Condition
Exception

Throws if the source type or destination type isn't an enum type

| Edit this page View Source

RawConvert<SourceEnumType, DestEnumType>(SourceEnumType)

Forcefully converts from one enum to another

Declaration
public static DestEnumType RawConvert<SourceEnumType, DestEnumType>(SourceEnumType source)
Parameters
Type Name Description
SourceEnumType source

The enum value to convert

Returns
Type Description
DestEnumType

Returns the forcefully converted enum value

Type Parameters
Name Description
SourceEnumType

The source enum type

DestEnumType

The destination enum type

  • Edit this page
  • View Source
☀
☾
In this article
Back to top
Generated by DocFX
☀
☾