Пример #1
0
        private void LoadStruct(TreeNode parentNode, Type td)
        {
            TreeNode node;
            if (td.IsPublic)
            {
                node = new ClassTreeNode(td, ClassType.Struct, Access.Public);
                parentNode.Nodes.Add(node);
            }
            else if (td.IsNestedPrivate)
            {
                node = new ClassTreeNode(td, ClassType.Struct, Access.Private);
                parentNode.Nodes.Add(node);
            }
            else if (td.IsNestedFamORAssem)
            {
                node = new ClassTreeNode(td, ClassType.Struct, Access.Internal);
                parentNode.Nodes.Add(node);
            }
            else
            {
                // It must be protected.
                node = new ClassTreeNode(td, ClassType.Struct, Access.Protected);
                parentNode.Nodes.Add(node);
            }


            foreach (Type ntd in td.GetNestedTypes())
            {
                LoadType(node, ntd);
            }
            foreach (MethodInfo md in td.GetMethods())
            {
                LoadMethod(node, md);
            }
            foreach (Type ntd in td.GetInterfaces())
            {
                LoadImplementedInterface(node, ntd);
            }
            foreach (EventInfo ed in td.GetEvents())
            {
                LoadEvent(node, ed);
            }
            foreach (PropertyInfo pd in td.GetProperties())
            {
                LoadProperty(node, pd);
            }
            foreach (FieldInfo fd in td.GetFields())
            {
                LoadField(node, fd);
            }
        }
Пример #2
0
        private void LoadType(TreeNode parentNode, Type type)
        {
            if (!type.IsEnum && !type.IsInterface && !type.IsValueType && type.IsClass)
            {
                TreeNode node;
                if (type.IsPublic)
                {
                    node = new ClassTreeNode(type, ClassType.Class, Access.Public);
                    parentNode.Nodes.Add(node);
                }
                else if (type.IsNestedPrivate)
                {
                    node = new ClassTreeNode(type, ClassType.Class, Access.Private);
                    parentNode.Nodes.Add(node);
                }
                else if (type.IsNestedFamORAssem)
                {
                    node = new ClassTreeNode(type, ClassType.Class, Access.Internal);
                    parentNode.Nodes.Add(node);
                }
                else
                {
                    // It must be Protected.
                    node = new ClassTreeNode(type, ClassType.Class, Access.Protected);
                    parentNode.Nodes.Add(node);
                }


                //TreeNode node = (treeView1.Nodes.Find(type.FullName, true))[0];
                foreach (Type ntd in type.GetNestedTypes())
                {
                    LoadType(node, ntd);
                }
                foreach (MethodInfo md in type.GetMethods())
                {
                    LoadMethod(node, md);
                }
                foreach (Type ntd in type.GetInterfaces())
                {
                    LoadImplementedInterface(node, ntd);
                }
                foreach (EventInfo ed in type.GetEvents())
                {
                    LoadEvent(node, ed);
                }
                foreach (PropertyInfo pd in type.GetProperties())
                {
                    LoadProperty(node, pd);
                }
                foreach (FieldInfo fd in type.GetFields())
                {
                    LoadField(node, fd);
                }
            }
            else if (type.IsEnum)
            {
                LoadEnum(parentNode, type);
            }
            else if (type.IsInterface)
            {
                LoadInterface(parentNode, type.GetElementType());
            }
            else if (type.IsValueType)
            {
                LoadStruct(parentNode, type);
            }
            else
            {
                throw new Exception();
            }
        }
Пример #3
0
        //private void LoadConstant(TreeNode parentNode, PropertyInfo ptd)
        //{
        //    //TreeNode tr = new FieldTreeNode(fd, Access.Protected, false);
        //    //parentNode.Nodes.Add(tr);
        //    parentNode.Nodes.Add(ptd.FullName, ptd.Name, Constants.ConstantIcon, Constants.ConstantIcon);
        //}

        #region LoadEnum
        private void LoadEnum(TreeNode parentNode, Type td)
        {
            TreeNode enode;
            TreeNode tr;
            if (td.IsPublic)
            {
                enode = new ClassTreeNode(td, ClassType.Enum, Access.Public);
                parentNode.Nodes.Add(enode);
            }
            else if (td.IsNestedPrivate)
            {
                enode = new ClassTreeNode(td, ClassType.Enum, Access.Private);
                parentNode.Nodes.Add(enode);
            }
            else if (td.IsNestedFamORAssem)
            {
                enode = new ClassTreeNode(td, ClassType.Enum, Access.Internal);
                parentNode.Nodes.Add(enode);
            }
            else
            {
                // It must be protected.
                enode = new ClassTreeNode(td, ClassType.Enum, Access.Protected);
                parentNode.Nodes.Add(enode);
            }
            // Now we get to load it's values.
            foreach (FieldInfo fd in td.GetFields())
            {
                // We don't want to show "value__" because it's automatically added 
                // by the compiler.
                if (fd.Name != "value__")
                {
                    tr = new FieldTreeNode(fd, Access.Public, true);
                    enode.Nodes.Add(tr);
                }
            }
        }