// Token: 0x0600806E RID: 32878 private void RenderContentInfoRecursive(MemoryProfiler.ObjectContentInfo content, int depth, float spaceWidth, ref int renderedLines, int viewPortStartLine, int viewPortEndLine, ref int skippedLines, float lineHeight, string[] reflectPath) { if (content == null) { return; } if (renderedLines == 0 || (renderedLines <= viewPortEndLine && renderedLines >= viewPortStartLine)) { if (skippedLines > 0) { GUILayout.Space(lineHeight * (float)skippedLines); skippedLines = 0; } GUILayout.BeginHorizontal(Array.Empty <GUILayoutOption>()); GUILayout.Space(spaceWidth * (float)depth); if (content.contentInfo != null) { if (GUILayout.Button(content.isFolded ? ">" : "v", new GUILayoutOption[] { GUILayout.Width(20f) })) { content.isFolded = !content.isFolded; } } else { GUILayout.Box("o", new GUILayoutOption[] { GUILayout.Width(20f) }); } GUILayout.Box(content.typeText, this.boxReflectFontStyle, new GUILayoutOption[] { GUILayout.Width(200f) }); GUILayout.Box(content.nameText, this.boxReflectFontStyle, new GUILayoutOption[] { GUILayout.Width(200f) }); GUILayout.Box(content.valueText, this.boxReflectFontStyle, Array.Empty <GUILayoutOption>()); GUILayout.EndHorizontal(); } else { skippedLines++; } renderedLines++; if (content.contentInfo != null && !content.isFolded) { string pathTypeString = null; string pathNameString = null; if (reflectPath.Length > (depth + 1)) { string pathString = reflectPath[depth + 1]; if (pathString.EndsWith("@type")) { pathTypeString = pathString.Substring(0, pathString.Length - "@type".Length); } else { pathNameString = pathString; } if (string.Equals(pathTypeString, "*")) { pathTypeString = null; } if (string.Equals(pathNameString, "*")) { pathNameString = null; } } foreach (MemoryProfiler.ObjectContentInfo innerContent in content.contentInfo) { if (pathTypeString != null && !InputPartiallyMatches(pathTypeString, innerContent.typeString)) { continue; } if (pathNameString != null && !InputPartiallyMatches(pathNameString, innerContent.nameString)) { continue; } this.RenderContentInfoRecursive(innerContent, depth + 1, spaceWidth, ref renderedLines, viewPortStartLine, viewPortEndLine, ref skippedLines, lineHeight, reflectPath); } } }
// Token: 0x06007EFC RID: 32508 private static List <MemoryProfiler.ObjectContentInfo> buildContentInfoRecursive(object value, int depth, List <object> objectHistory) { if (value == null) { return(null); } if (depth > 15) { return(null); } if (objectHistory.Contains(value)) { return(null); } objectHistory.Add(value); Type type = value.GetType(); if (type.IsPrimitive) { return(null); } if (typeof(string).IsInstanceOfType(value)) { return(null); } if (typeof(DateTime).IsInstanceOfType(value)) { return(null); } List <MemoryProfiler.ObjectContentInfo> result = new List <MemoryProfiler.ObjectContentInfo>(); try { if (type.IsEnum) { foreach (string enumName in type.GetEnumNames()) { result.Add(new MemoryProfiler.ObjectContentInfo("Enum", type.Name, enumName)); } } else if (typeof(Array).IsAssignableFrom(type)) { Array array = (Array)value; int length = array.GetLength(0); for (int index = 0; index < length; index++) { object arrayValue = array.GetValue(index); MemoryProfiler.ObjectContentInfo arrayContentInfo = new MemoryProfiler.ObjectContentInfo(arrayValue.GetType().Name, "arr_" + index, arrayValue); result.Add(arrayContentInfo); arrayContentInfo.contentInfo = MemoryProfiler.buildContentInfoRecursive(arrayValue, depth + 1, objectHistory); } } else if (type.GetInterfaces().Where(t => t.IsGenericType && t.GetGenericTypeDefinition() == typeof(IDictionary <,>)).Any()) { IDictionary <object, object> dictionary = (IDictionary <object, object>)value; foreach (KeyValuePair <object, object> kvp in dictionary) { MemoryProfiler.ObjectContentInfo enumerableContentInfo = new MemoryProfiler.ObjectContentInfo(kvp.Key.GetType().Name, "dict[" + kvp.Key.ToString() + "]", kvp.Value); result.Add(enumerableContentInfo); enumerableContentInfo.contentInfo = MemoryProfiler.buildContentInfoRecursive(kvp.Value, depth + 1, objectHistory); } } else if (type.GetInterfaces().Where(t => t.IsGenericType && t.GetGenericTypeDefinition() == typeof(IEnumerable <>)).Any()) { IEnumerable <object> enumerable = (IEnumerable <object>)value; int quasiIndex = 0; foreach (object item in enumerable) { MemoryProfiler.ObjectContentInfo enumerableContentInfo = new MemoryProfiler.ObjectContentInfo(item.GetType().Name, "enumerable~" + quasiIndex, item); result.Add(enumerableContentInfo); enumerableContentInfo.contentInfo = MemoryProfiler.buildContentInfoRecursive(item, depth + 1, objectHistory); quasiIndex++; } } else { foreach (FieldInfo fieldInfo in type.GetFields(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public)) { object fieldValue = fieldInfo.GetValue(value); MemoryProfiler.ObjectContentInfo fieldContentInfo = new MemoryProfiler.ObjectContentInfo(fieldInfo.FieldType.Name, fieldInfo.Name, fieldValue); result.Add(fieldContentInfo); fieldContentInfo.contentInfo = MemoryProfiler.buildContentInfoRecursive(fieldValue, depth + 1, objectHistory); } if (MemoryProfiler.reflectOnProperties) { foreach (PropertyInfo propertyInfo in type.GetProperties()) { if (propertyInfo.CanRead) { ParameterInfo[] parameters = propertyInfo.GetIndexParameters(); if (parameters.GetLength(0) != 0) { ObjectContentInfo indexedPropContentInfo = new ObjectContentInfo(propertyInfo.PropertyType.Name, propertyInfo.Name, "[can't reflect on indexed property! listing parameters instead]"); result.Add(indexedPropContentInfo); List <ObjectContentInfo> parameterInfo = new List <ObjectContentInfo>(); foreach (ParameterInfo parameter in parameters) { string defaultParamValue = parameter.HasDefaultValue ? parameter.DefaultValue.ToString() : "none"; parameterInfo.Add(new ObjectContentInfo(parameter.ParameterType.Name, parameter.Name, "default: " + defaultParamValue)); } indexedPropContentInfo.contentInfo = parameterInfo; } else { object propertyValue = propertyInfo.GetValue(value); if (propertyValue != null && !propertyValue.GetType().IsAssignableFrom(type)) { MemoryProfiler.ObjectContentInfo propContentInfo = new MemoryProfiler.ObjectContentInfo(propertyInfo.PropertyType.Name, propertyInfo.Name, propertyValue); result.Add(propContentInfo); propContentInfo.contentInfo = MemoryProfiler.buildContentInfoRecursive(propertyValue, depth + 1, objectHistory); } } } } } } } catch (Exception e) { Debug.LogWarning("reflection usage failed, error: " + e.ToString()); return(new List <ObjectContentInfo>() { new ObjectContentInfo("error", "encountered error", e) }); } return(result); }