Class EnumerationExtensions
Handy extension methods for Flags-Enums. Taken from http://hugoware.net/blog/enums-flags-and-csharp
Inheritance
System.Object
EnumerationExtensions
Inherited Members
System.Object.ToString()
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
Namespace: OPTANO.Modeling.Common
Assembly: Common.dll
Syntax
public static class EnumerationExtensions
Methods
Add<T>(Enum, T)
Declaration
public static T Add<T>(this Enum type, T value)
Parameters
Type | Name | Description |
---|---|---|
System.Enum | type | |
T | value |
Returns
Type | Description |
---|---|
T |
Type Parameters
Name | Description |
---|---|
T |
Has<T>(Enum, T)
Checks if the value contains the provided type.
It is NOT
validated whether type.GetType() == typeof(T). Only the respective int-casts are compared!
Declaration
public static bool Has<T>(this Enum type, T value)
Parameters
Type | Name | Description |
---|---|---|
System.Enum | type | The extended System.Enum. |
T | value | The flag to check for. |
Returns
Type | Description |
---|---|
System.Boolean | True, if the |
Type Parameters
Name | Description |
---|---|
T | The flag enum type, that you want to check against. |
Is<T>(Enum, T)
Declaration
public static bool Is<T>(this Enum type, T value)
Parameters
Type | Name | Description |
---|---|---|
System.Enum | type | |
T | value |
Returns
Type | Description |
---|---|
System.Boolean |
Type Parameters
Name | Description |
---|---|
T |
Remove<T>(Enum, T)
Declaration
public static T Remove<T>(this Enum type, T value)
Parameters
Type | Name | Description |
---|---|---|
System.Enum | type | |
T | value |
Returns
Type | Description |
---|---|
T |
Type Parameters
Name | Description |
---|---|
T |