예제 #1
0
 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);
 }
예제 #2
0
 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);
             }
         }
     }
 }
예제 #3
0
        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);
                }
            }
        }
예제 #4
0
 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;
 }
예제 #5
0
        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);
                }
            }
        }