public void Analyze(Type topLevelType)
 {
     _root = new MemberAnalysis(topLevelType, topLevelType.Name);
     _desc.Clear();
     _leafCustomPaths.Clear();
     this._desc.AppendFormat("{0}{1}", topLevelType.Name, "\n");
     this.GetTypeDescription(_desc, _root);
     this.GetLeafCustomPaths(this._root, _leafCustomPaths);
 }
 private void GetLeafCustomPaths(MemberAnalysis ca, List<string> paths)
 {
     if (ca.IsLeafCustom)
     {
         paths.Add(ca.Path);
     }
     else
     {
         if (ca.ChildClasses != null)
         {
             foreach (MemberAnalysis child in ca.ChildClasses)
             {
                 GetLeafCustomPaths(child, paths);
             }
         }
     }
 }
        private void GetTypeDescription(StringBuilder sb, MemberAnalysis ca, int indent = 0)
        {
            foreach (FieldInfo field in ca.Type.GetFields())
            {
                MemberAnalysis child = ca.AddChildClass(field);

                sb.AppendFormat(
                    "{0}{1} {2}{3}",
                    GetIndent(indent + 1),
                    child.MemberTypeDesc,
                    child.Name,
                    "\n"
                );

                if (!child.Type.FullName.StartsWith("System") && !child.Type.IsEnum)
                {
                    GetTypeDescription(sb, child, indent + 1);
                }
            }

            foreach (PropertyInfo prop in ca.Type.GetProperties())
            {
                MemberAnalysis child = ca.AddChildClass(prop);

                sb.AppendFormat(
                    "{0}{1} {2}{3}",
                    GetIndent(indent + 1),
                    child.MemberTypeDesc,
                    child.Name,
                    "\n"
                );

                if (!child.Type.FullName.StartsWith("System") && !child.Type.IsEnum)
                {
                    GetTypeDescription(sb, child, indent + 1);
                }
            }
        }
 public MemberAnalysis AddChildClass(PropertyInfo value)
 {
     if (this.ChildClasses == null)
     {
         this.ChildClasses = new List<MemberAnalysis>();
     }
     MemberAnalysis ca = new MemberAnalysis(value);
     ca.Parent = this;
     this.ChildClasses.Add(ca);
     return ca;
 }
        private void GetTypes(MemberAnalysis parent, IList<Type> types)
        {
            if (!types.Contains(parent.Type) && !parent.Type.FullName.StartsWith("System"))
            {
                types.Add(parent.Type);
            }

            if (parent.ChildClasses != null)
            {
                foreach (MemberAnalysis child in parent.ChildClasses)
                {
                    GetTypes(child, types);
                }
            }
        }