Ignore:
Timestamp:
08/06/13 16:36:11 (9 years ago)
Author:
jkarder
Message:

#2095

  • added FieldInfo cache
  • refactored GetAllFields to work iteratively
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Common/3.3/TypeExtensions.cs

    r9456 r9855  
    4949
    5050    public static IEnumerable<FieldInfo> GetAllFields(this Type type) {
    51       foreach (var field in type.GetFields(BindingFlags.Instance | BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.NonPublic))
    52         yield return field;
    53 
    54       foreach (var field in type.GetFields(BindingFlags.Static | BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.NonPublic))
    55         yield return field;
    56 
    57       if (type.BaseType != null) {
    58         foreach (var field in type.BaseType.GetAllFields())
     51      while (type != null) {
     52        foreach (var field in type.GetFields(BindingFlags.Static | BindingFlags.Instance | BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.NonPublic))
    5953          yield return field;
     54        type = type.BaseType;
    6055      }
    6156    }
Note: See TracChangeset for help on using the changeset viewer.