|
|
@ -172,35 +172,34 @@ namespace Volo.Abp.Reflection |
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
/// <param name="type"></param>
|
|
|
/// <param name="type"></param>
|
|
|
/// <returns></returns>
|
|
|
/// <returns></returns>
|
|
|
public static string[] GetAllConstants(Type type) |
|
|
public static string[] GetPublicConstantsRecursively(Type type) |
|
|
{ |
|
|
|
|
|
var constants = new List<string>(); |
|
|
|
|
|
GetAllConstantsRecursively(constants, type, 1); |
|
|
|
|
|
return constants.ToArray(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private static void GetAllConstantsRecursively(List<string> constants, Type type, int currentDepth) |
|
|
|
|
|
{ |
|
|
{ |
|
|
const int maxRecursiveParameterValidationDepth = 8; |
|
|
const int maxRecursiveParameterValidationDepth = 8; |
|
|
|
|
|
|
|
|
if (currentDepth > maxRecursiveParameterValidationDepth) |
|
|
var publicConstants = new List<string>(); |
|
|
|
|
|
|
|
|
|
|
|
void Recursively(List<string> constants, Type targetType, int currentDepth) |
|
|
{ |
|
|
{ |
|
|
return; |
|
|
if (currentDepth > maxRecursiveParameterValidationDepth) |
|
|
} |
|
|
{ |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
constants.AddRange( |
|
|
constants.AddRange(targetType.GetFields(BindingFlags.Public | BindingFlags.Static | BindingFlags.FlattenHierarchy) |
|
|
type.GetFields(BindingFlags.Public | BindingFlags.Static | BindingFlags.FlattenHierarchy) |
|
|
|
|
|
.Where(x => x.IsLiteral && !x.IsInitOnly) |
|
|
.Where(x => x.IsLiteral && !x.IsInitOnly) |
|
|
.Select(x => x.GetValue(null).ToString()) |
|
|
.Select(x => x.GetValue(null).ToString())); |
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
var nestedTypes = type.GetNestedTypes(BindingFlags.Public); |
|
|
var nestedTypes = targetType.GetNestedTypes(BindingFlags.Public); |
|
|
|
|
|
|
|
|
foreach (var nestedType in nestedTypes) |
|
|
foreach (var nestedType in nestedTypes) |
|
|
{ |
|
|
{ |
|
|
GetAllConstantsRecursively(constants, nestedType, currentDepth + 1); |
|
|
Recursively(constants, nestedType, currentDepth + 1); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Recursively(publicConstants, type, 1); |
|
|
|
|
|
|
|
|
|
|
|
return publicConstants.ToArray(); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|