Class EnumHelper<TEnum>
Stellt typsichere Enum-Methoden zur Verfügung.
Inheritance
Inherited Members
Namespace: Dataport.AppFrameDotNet.DotNetTools.Reflection
Assembly: Dataport.AppFrameDotNet.DotNetTools.dll
Syntax
public static class EnumHelper<TEnum>
    where TEnum : Enum
  Type Parameters
| Name | Description | 
|---|---|
| TEnum | Der Typ des Enums  | 
      
Methods
AsDictionary()
Überführt das Enum in ein Dictionary.
Declaration
public static IDictionary<int, string> AsDictionary()
  Returns
| Type | Description | 
|---|---|
| System.Collections.Generic.IDictionary<System.Int32, System.String> | Die Dictionary-Representation des Enums  | 
      
AsDictionary<TKey>()
Überführt das Enum in ein Dictionary.
Declaration
public static IDictionary<TKey, string> AsDictionary<TKey>()
  Returns
| Type | Description | 
|---|---|
| System.Collections.Generic.IDictionary<TKey, System.String> | Die Dictionary-Representation des Enums  | 
      
Type Parameters
| Name | Description | 
|---|---|
| TKey | Der Key-Typ des Enums  | 
      
ChangeType<TOut>(TEnum, Boolean)
Parst ein Enum-Value in ein Value eines anderen Typen.
Verhalten: Der abgesicherte Modus (strict = true) stellt sicher, dass alle Wert-Index-Paare
von TEnum in TOut existieren um Laufzeitfehler zu verhindern.
Im ungesicherten Modus (strict = false) wird zuerst anhand des Namens, dann anhand des Index überführt.
Declaration
public static TOut ChangeType<TOut>(TEnum value, bool strict = false)
    where TOut : struct, Enum
  Parameters
| Type | Name | Description | 
|---|---|---|
| TEnum | value | Der zu überführende Wert.  | 
      
| System.Boolean | strict | 
Returns
| Type | Description | 
|---|---|
| TOut | 
Type Parameters
| Name | Description | 
|---|---|
| TOut | Der neue Typ des Wertes.  | 
      
Exceptions
| Type | Condition | 
|---|---|
| System.ArgumentException | Das Parsen funktioniert nicht ODER (bei strict = true) nicht alle Ausprägungen des Enums sind im Zielenum enthalten.  | 
      
Count()
Gibt die Anzahl der Enum-Values zurück.
Declaration
public static int Count()
  Returns
| Type | Description | 
|---|---|
| System.Int32 | Die Anzahl der Values.  | 
      
FitsByIndexInto<TOther>()
Gibt an, ob das Enum mit all seinen Indexen vollständig von einem anderen Enum abgedeckt wird.
Declaration
public static bool FitsByIndexInto<TOther>()
    where TOther : Enum
  Returns
| Type | Description | 
|---|---|
| System.Boolean | true wenn das Enum passt, andernfalls false  | 
      
Type Parameters
| Name | Description | 
|---|---|
| TOther | Der Typ des anderen Enums  | 
      
FitsByNameInto<TOther>()
Gibt an, ob das Enum mit all seinen Namen vollständig von einem anderen Enum abgedeckt wird.
Declaration
public static bool FitsByNameInto<TOther>()
    where TOther : Enum
  Returns
| Type | Description | 
|---|---|
| System.Boolean | true wenn das Enum passt, andernfalls false  | 
      
Type Parameters
| Name | Description | 
|---|---|
| TOther | Der Typ des anderen Enums  | 
      
FitsInto<TOther>()
Gibt an, ob das Enum mit all seinen Index-Wert-Kombinationen vollständig von einem anderes Enum abgedeckt wird.
Declaration
public static bool FitsInto<TOther>()
    where TOther : Enum
  Returns
| Type | Description | 
|---|---|
| System.Boolean | true wenn das Enum passt, andernfalls false  | 
      
Type Parameters
| Name | Description | 
|---|---|
| TOther | Der Typ des anderen Enums  | 
      
GetValues()
Gibt alle Values des Enums zurück.
Declaration
public static IEnumerable<TEnum> GetValues()
  Returns
| Type | Description | 
|---|---|
| System.Collections.Generic.IEnumerable<TEnum> | Alle Values des Enums.  | 
      
GetValuesWhereAttribute<TAttribute>(Func<TAttribute, Boolean>)
Gibt alle Values des Enums anhand eines Predikats über ein Attribut an den Membern zurück. Verhalten: Member die nicht über das Attribut verfügen werden ignoriert.
Declaration
public static IEnumerable<TEnum> GetValuesWhereAttribute<TAttribute>(Func<TAttribute, bool> condition)
    where TAttribute : Attribute
  Parameters
| Type | Name | Description | 
|---|---|---|
| System.Func<TAttribute, System.Boolean> | condition | Bedingung, welche die Attribute erfüllen müssen.  | 
      
Returns
| Type | Description | 
|---|---|
| System.Collections.Generic.IEnumerable<TEnum> | Alle Values deren Attribute die übergebene Bedingung erfüllen.  | 
      
Type Parameters
| Name | Description | 
|---|---|
| TAttribute | Der Typ des Attributs  | 
      
IsSubstituteOf<TOther>()
Gibt an, ob das Enum vollständig kongruent zu einem anderen Enum ist.
Declaration
public static bool IsSubstituteOf<TOther>()
    where TOther : Enum
  Returns
| Type | Description | 
|---|---|
| System.Boolean | true wenn die Enums kongruent sind, andernfalls false  | 
      
Type Parameters
| Name | Description | 
|---|---|
| TOther | Der Typ des anderen Enums  |