Free cookie consent management tool by TermsFeed Policy Generator

Changeset 6500


Ignore:
Timestamp:
07/04/11 13:07:34 (11 years ago)
Author:
mkommend
Message:

#1569: Added special handling for ThreadLocal<> in Object.GetObjectGraphObjects().

File:
1 edited

Legend:

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

    r6380 r6500  
    2626using System.Linq;
    2727using System.Reflection;
     28using System.Threading;
    2829
    2930namespace HeuristicLab.Common {
     
    3839      while (stack.Count > 0) {
    3940        object current = stack.Pop();
    40         Type type = obj.GetType();
    4141        objects.Add(current);
    4242
     
    7171      Type type = obj.GetType();
    7272
    73       if (type.IsSubclassOfRawGeneric(typeof(Dictionary<,>)) ||
    74          type.IsSubclassOfRawGeneric(typeof(SortedDictionary<,>)) ||
    75          type.IsSubclassOfRawGeneric(typeof(SortedList<,>)) ||
    76          obj is SortedList ||
    77          obj is OrderedDictionary ||
    78          obj is ListDictionary ||
    79          obj is Hashtable) {
     73      if (type.IsSubclassOfRawGeneric(typeof(ThreadLocal<>))) {
     74        PropertyInfo info = type.GetProperty("Value");
     75        object value = info.GetValue(obj, null);
     76        if (value != null) yield return value;
     77      } else if (type.IsSubclassOfRawGeneric(typeof(Dictionary<,>)) ||
     78           type.IsSubclassOfRawGeneric(typeof(SortedDictionary<,>)) ||
     79           type.IsSubclassOfRawGeneric(typeof(SortedList<,>)) ||
     80           obj is SortedList ||
     81           obj is OrderedDictionary ||
     82           obj is ListDictionary ||
     83           obj is Hashtable) {
    8084        var dictionary = obj as IDictionary;
    8185        foreach (object value in dictionary.Keys)
Note: See TracChangeset for help on using the changeset viewer.