Changeset 7139


Ignore:
Timestamp:
12/06/11 18:04:29 (8 years ago)
Author:
epitzer
Message:

#1701 Catch SecurityExceptions while accessing fields during object graph traversal.

File:
1 edited

Legend:

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

    r6891 r7139  
    2626using System.Linq;
    2727using System.Reflection;
     28using System.Security;
    2829using System.Threading;
    2930
     
    9596        foreach (FieldInfo f in type.GetAllFields()) {
    9697          if (excludeStaticMembers && f.IsStatic) continue;
    97           yield return f.GetValue(obj);
     98          object fieldValue;
     99          try {
     100            fieldValue = f.GetValue(obj);
     101          } catch (SecurityException) {
     102            continue;
     103          }
     104          yield return fieldValue;
    98105        }
    99106      }
Note: See TracChangeset for help on using the changeset viewer.