Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
05/11/11 13:44:50 (13 years ago)
Author:
mkommend
Message:

#1522: Reorganized type checks and added a clause to exclude primitive arrays from being enumerated.

File:
1 edited

Legend:

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

    r6119 r6181  
    3434
    3535    private static void CollectObjectGraphObjects(this object obj, HashSet<object> objects) {
    36       if (obj == null || obj is Delegate || obj is EventHandler || obj.GetType().IsSubclassOfRawGeneric(typeof(EventHandler<>)) || objects.Contains(obj)) return;
     36      if (obj == null || objects.Contains(obj)) return;
     37      if (obj is ValueType || obj is string) return;
     38      if (obj is Delegate || obj is EventHandler) return;
     39      if (obj.GetType().IsSubclassOfRawGeneric(typeof(EventHandler<>))) return;
     40      if (obj.GetType().GetElementType() != null) {
     41        Type elementType = obj.GetType().GetElementType();
     42        if (elementType.IsPrimitive || elementType == typeof(string) || elementType == typeof(decimal)) return;
     43      }
     44
    3745      objects.Add(obj);
    38 
    39       if (obj is ValueType || obj is string) return;
    4046
    4147      IEnumerable enumerable = obj as IEnumerable;
Note: See TracChangeset for help on using the changeset viewer.