Created
October 9, 2017 15:59
-
-
Save nycdotnet/43dc3484dd050190296020862141fff9 to your computer and use it in GitHub Desktop.
Get Constants On Type
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <summary> | |
/// Enumerates constants on a type. | |
/// </summary> | |
public static IEnumerable<FieldInfo> GetConstantsOnType(Type TypeToReflect) | |
{ | |
return TypeToReflect.GetFields().Where(f => f.IsStatic && f.IsLiteral); | |
} | |
/// <summary> | |
/// Enumerates constants on a type of a type. | |
/// </summary> | |
public static IEnumerable<FieldInfo> GetConstantsOnTypeOfType(Type TypeToReflect, Type TypeToFind) | |
{ | |
return GetConstantsOnType(TypeToReflect).Where(f => f.FieldType == TypeToFind); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment