Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
03/15/12 09:11:17 (13 years ago)
Author:
gkronber
Message:

#1081 merged r7462:7609 from trunk into time series branch

Location:
branches/HeuristicLab.TimeSeries
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.TimeSeries

  • branches/HeuristicLab.TimeSeries/HeuristicLab.Common/3.3/ObjectExtensions.cs

    r7268 r7615  
    3131namespace HeuristicLab.Common {
    3232  public static class ObjectExtensions {
    33     public static IEnumerable<object> GetObjectGraphObjects(this object obj, bool excludeStaticMembers = false) {
     33    public static IEnumerable<object> GetObjectGraphObjects(this object obj, HashSet<string> excludedMembers = null, bool excludeStaticMembers = false) {
    3434      if (obj == null) return Enumerable.Empty<object>();
     35      if (excludedMembers == null) excludedMembers = new HashSet<string>();
    3536
    3637      var objects = new HashSet<object>();
     
    4243        objects.Add(current);
    4344
    44         foreach (object o in GetChildObjects(current, excludeStaticMembers)) {
     45        foreach (object o in GetChildObjects(current, excludedMembers, excludeStaticMembers)) {
    4546          if (o != null && !objects.Contains(o) && !ExcludeType(o.GetType()))
    4647            stack.Push(o);
     
    7071             (type.HasElementType && ExcludeType(type.GetElementType()));
    7172    }
    72     private static IEnumerable<object> GetChildObjects(object obj, bool excludeStaticMembers) {
     73    private static IEnumerable<object> GetChildObjects(object obj, HashSet<string> excludedMembers, bool excludeStaticMembers) {
    7374      Type type = obj.GetType();
    7475
     
    9596      } else {
    9697        foreach (FieldInfo f in type.GetAllFields()) {
     98          if (excludedMembers.Contains(f.Name)) continue;
    9799          if (excludeStaticMembers && f.IsStatic) continue;
    98100          object fieldValue;
    99101          try {
    100102            fieldValue = f.GetValue(obj);
    101           } catch (SecurityException) {
     103          }
     104          catch (SecurityException) {
    102105            continue;
    103106          }
Note: See TracChangeset for help on using the changeset viewer.