Changeset 1279
- Timestamp:
- 03/06/09 17:19:08 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/New Persistence Exploration/Persistence/Persistence/Util.cs
r1274 r1279 10 10 } 11 11 public static string AutoFormat(object o, bool recursive) { 12 Dictionary<object, int> visitedObjects = new Dictionary<object,int>(); 13 return AutoFormat(o, recursive, visitedObjects); 14 } 15 private static string AutoFormat(object o, bool recursive, Dictionary<object, int> visitedObjects) { 12 16 string s = o as string; 13 17 if (s != null) … … 15 19 if (o == null) { 16 20 return "<null>"; 21 } 22 if (visitedObjects.ContainsKey(o)) { 23 return o.ToString(); 24 } else { 25 visitedObjects.Add(o, 0); 26 } 27 if (o.ToString() != o.GetType().ToString()) { 28 return o.ToString(); 17 29 } 18 30 StringBuilder sb = new StringBuilder(); … … 24 36 BindingFlags.Instance)) { 25 37 if (mInfo.MemberType == MemberTypes.Field) { 38 FieldInfo fInfo = (FieldInfo)mInfo; 26 39 sb.Append(mInfo.Name); 27 sb.Append("="); 40 sb.Append("="); 28 41 if (recursive) { 29 sb.Append(AutoFormat(((FieldInfo)mInfo).GetValue(o) ));42 sb.Append(AutoFormat(((FieldInfo)mInfo).GetValue(o), true, visitedObjects)); 30 43 } else { 31 44 sb.Append(((FieldInfo)mInfo).GetValue(o));
Note: See TracChangeset
for help on using the changeset viewer.