Ejemplo n.º 1
0
        private void EnumerateAssembly(string filePath)
        {
            var assemblyEnumerator = new AssemblyEnumerator(filePath);

            foreach (var currentNameSpace in assemblyEnumerator.NameSpaces)
            {
                if (!string.IsNullOrEmpty(currentNameSpace))
                {
                    var namespaceTreeNode = new TreeNode(currentNameSpace);

                    bool hasClasses = false;

                    foreach (var classType in assemblyEnumerator.GetClasses(currentNameSpace))
                    {
                        bool hasMethods = false;
                        var classTreeNode = new TreeNode(classType.Name);

                        foreach (var method in assemblyEnumerator.GetMethodds(classType))
                        {
                            if (!method.IsGenericMethod)
                            {
                                var methodBase = method.GetMethodBase();
                                if (methodBase != null)
                                {
                                    var methodTreeNode = new TreeNode(method.GetFriendlyName());
                                    methodTreeNode.Tag = methodBase;

                                    bool hasExceptions;

                                    try
                                    {
                                        hasExceptions = method.HasAnyExceptions();
                                    }
                                    catch (ArgumentException)
                                    {
                                        hasExceptions = false;
                                    }

                                    methodTreeNode.ForeColor = hasExceptions ? Color.Black : Color.DarkGray;
                                    classTreeNode.Nodes.Add(methodTreeNode);
                                    hasMethods = true;
                                }
                            }
                        }

                        if (hasMethods)
                        {
                            namespaceTreeNode.Nodes.Add(classTreeNode);
                            hasClasses = true;
                        }

                    }

                    if (hasClasses)
                    {
                        this.itemTreeView.Nodes.Add(namespaceTreeNode);
                    }
                }
            }
        }