Changeset 14144 for trunk/sources
- Timestamp:
- 07/21/16 07:17:25 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Common/3.3/ObjectExtensions.cs
r14032 r14144 31 31 namespace HeuristicLab.Common { 32 32 33 [AttributeUsage( System.AttributeTargets.Field)]33 [AttributeUsage(AttributeTargets.Field)] 34 34 // this attribute can be used to mark fields that should be excluded from object graph traversal 35 35 public class ExcludeFromObjectGraphTraversalAttribute : Attribute { … … 119 119 } 120 120 } else { 121 if (!fieldInfos.ContainsKey(type)) 122 fieldInfos[type] = type.GetAllFields() 123 .Where(fi => !fi.GetCustomAttributes<ExcludeFromObjectGraphTraversalAttribute>().Any()) 121 FieldInfo[] fieldInfo; 122 if (!fieldInfos.TryGetValue(type, out fieldInfo)) { 123 fieldInfo = type.GetAllFields() 124 .Where(fi => !Attribute.IsDefined(fi, typeof(ExcludeFromObjectGraphTraversalAttribute))) 124 125 .ToArray(); 125 foreach (FieldInfo f in fieldInfos[type]) { 126 fieldInfos.Add(type, fieldInfo); 127 } 128 foreach (FieldInfo f in fieldInfo) { 126 129 if (excludeStaticMembers && f.IsStatic) continue; 127 130 object fieldValue; 128 131 try { 129 132 fieldValue = f.GetValue(obj); 130 } 131 catch (SecurityException) { 133 } catch (SecurityException) { 132 134 continue; 133 135 }
Note: See TracChangeset
for help on using the changeset viewer.