UnityHeapEx.HeapDump.GatherFromRootRecursively C# (CSharp) Méthode

GatherFromRootRecursively() public méthode

Works through all fields of an object, dumpoing them into xml
public GatherFromRootRecursively ( object root, string depth ) : int
root object
depth string
Résultat int
        public int GatherFromRootRecursively(object root, string depth)
        {
            var seen = seenObjects.Contains( root );

            if( root is Object )
            {
                var uo = root as Object;
                WriteUnityObjectData( depth, uo, seen );
            }

            if( seen )
            {
                if(!(root is Object))
                {
                    // XXX maybe add some object index so that this is traceable to original object dump
                    // earlier in xml?
                    writer.WriteLine( depth + "<seen/>" );

                }
                return 0;
            }

            seenObjects.Add( root );

            var type = root.GetType();
            var fields = type.EnumerateAllFields();
            var res = 0;
            foreach( var fieldInfo in fields )
            {
                try
                {
                    res += ReportField( root, depth, fieldInfo );
                }
                catch( Exception ex )
                {
                    writer.WriteLine( "Exception: " + ex.Message + " on " + fieldInfo.FieldType.GetFormattedName() + " " + fieldInfo.Name );
                }
            }
            return res;
        }