CapyKit/Docs/api/CapyKit.Extensions.EnumerationExtensions.md

176 lines
4.9 KiB
Markdown

# <a id="CapyKit_Extensions_EnumerationExtensions"></a> Class EnumerationExtensions
Namespace: [CapyKit.Extensions](CapyKit.Extensions.md)
Assembly: CapyKit.dll
Provides static extentions methods for providing additional functionality for <xref href="System.Enum" data-throw-if-not-resolved="false"></xref> types.
```csharp
public static class EnumerationExtensions
```
#### Inheritance
[object](https://learn.microsoft.com/dotnet/api/system.object) ←
[EnumerationExtensions](CapyKit.Extensions.EnumerationExtensions.md)
#### Inherited Members
[object.Equals\(object?\)](https://learn.microsoft.com/dotnet/api/system.object.equals\#system\-object\-equals\(system\-object\)),
[object.Equals\(object?, object?\)](https://learn.microsoft.com/dotnet/api/system.object.equals\#system\-object\-equals\(system\-object\-system\-object\)),
[object.GetHashCode\(\)](https://learn.microsoft.com/dotnet/api/system.object.gethashcode),
[object.GetType\(\)](https://learn.microsoft.com/dotnet/api/system.object.gettype),
[object.MemberwiseClone\(\)](https://learn.microsoft.com/dotnet/api/system.object.memberwiseclone),
[object.ReferenceEquals\(object?, object?\)](https://learn.microsoft.com/dotnet/api/system.object.referenceequals),
[object.ToString\(\)](https://learn.microsoft.com/dotnet/api/system.object.tostring)
#### Extension Methods
[ObjectExtensions.UpdateProperties\(object, object\)](CapyKit.Extensions.ObjectExtensions.md\#CapyKit\_Extensions\_ObjectExtensions\_UpdateProperties\_System\_Object\_System\_Object\_)
## Methods
### <a id="CapyKit_Extensions_EnumerationExtensions_GetDescription_System_Enum_"></a> GetDescription\(Enum\)
An <xref href="System.Enum" data-throw-if-not-resolved="false"></xref> extension method that gets a description.
```csharp
public static string GetDescription(this Enum enumeration)
```
#### Parameters
`enumeration` [Enum](https://learn.microsoft.com/dotnet/api/system.enum)
The enumeration to act on.
#### Returns
[string](https://learn.microsoft.com/dotnet/api/system.string)
The description if available, otherwise the string representation of the enumeration.
### <a id="CapyKit_Extensions_EnumerationExtensions_GetName_System_Enum_"></a> GetName\(Enum\)
An <xref href="System.Enum" data-throw-if-not-resolved="false"></xref> extension method that gets a name.
```csharp
public static string GetName(this Enum enumeration)
```
#### Parameters
`enumeration` [Enum](https://learn.microsoft.com/dotnet/api/system.enum)
The enumeration to act on.
#### Returns
[string](https://learn.microsoft.com/dotnet/api/system.string)
The name of the enumeration.
### <a id="CapyKit_Extensions_EnumerationExtensions_GetPrettyName_System_Enum_"></a> GetPrettyName\(Enum\)
An <xref href="System.Enum" data-throw-if-not-resolved="false"></xref> extension method that gets a human readable name.
```csharp
public static string GetPrettyName(this Enum enumeration)
```
#### Parameters
`enumeration` [Enum](https://learn.microsoft.com/dotnet/api/system.enum)
The enumeration to act on.
#### Returns
[string](https://learn.microsoft.com/dotnet/api/system.string)
The human readable name of the enumeration.
### <a id="CapyKit_Extensions_EnumerationExtensions_GetValue_System_Enum_"></a> GetValue\(Enum\)
An <xref href="System.Enum" data-throw-if-not-resolved="false"></xref> extension method that gets an integer value representing the enumation.
```csharp
public static int GetValue(this Enum enumeration)
```
#### Parameters
`enumeration` [Enum](https://learn.microsoft.com/dotnet/api/system.enum)
The enumeration to act on.
#### Returns
[int](https://learn.microsoft.com/dotnet/api/system.int32)
The integer value of the enumeration.
### <a id="CapyKit_Extensions_EnumerationExtensions_Parse__1___0_System_String_"></a> Parse<T\>\(T, string\)
A <code class="typeparamref">T</code> extension method that parses a string into an enumeration.
```csharp
public static T Parse<T>(this T enumeration, string value) where T : Enum
```
#### Parameters
`enumeration` T
The enumeration to act on.
`value` [string](https://learn.microsoft.com/dotnet/api/system.string)
The value.
#### Returns
T
A T.
#### Type Parameters
`T`
Generic type parameter.
### <a id="CapyKit_Extensions_EnumerationExtensions_Parse__1___0_System_String_System_Boolean_"></a> Parse<T\>\(T, string, bool\)
A <code class="typeparamref">T</code> extension method that parses a string into an enumeration.
```csharp
public static T Parse<T>(this T enumeration, string value, bool ignoreCase) where T : Enum
```
#### Parameters
`enumeration` T
The enumeration to act on.
`value` [string](https://learn.microsoft.com/dotnet/api/system.string)
The string value of the <xref href="System.Enum" data-throw-if-not-resolved="false"></xref>.
`ignoreCase` [bool](https://learn.microsoft.com/dotnet/api/system.boolean)
True to ignore case.
#### Returns
T
A T.
#### Type Parameters
`T`
Generic type parameter.