Esempio n. 1
0
 public ReferenceAssemblyElement(TreeNode node)
 {
     if (node.Tag is ReferenceAssemblyElement)
     {
         ReferenceAssemblyElement nodeTag = node.Tag as ReferenceAssemblyElement;
         if (nodeTag.ApplicationBase != null && nodeTag.ApplicationBase != string.Empty)
         {
             ApplicationBase = nodeTag.ApplicationBase;
         }
         if (nodeTag.AssemblyFileExists)
         {
             AssemblyFileLocation = nodeTag.AssemblyFileLocation;
         }
         else
         {
             return;
         }
         if (!AssemblyIsLoaded)
         {
             Autoload();
         }
     }
     else
     {
         throw new ArgumentException();
     }
 }
Esempio n. 2
0
        static public System.Reflection.Assembly ListNamespaces(
            TreeView treeView1,
            ReferenceAssemblyElement refasm)
        {
            System.Reflection.Assembly asm = refasm.Assembly;
            List <Type>     Types          = new List <Type>(asm.GetExportedTypes());
            List <TreeNode> Nodes          = new List <TreeNode>();

            treeView1.Nodes.Clear();
            foreach (string ns in Mirror.GetNamespaces(asm))
            {
                string names = ns == null?string.Empty:ns;
                DictionaryList <string, TreeNode> NodeSet = new DictionaryList <string, TreeNode>();
                NodeSet.CreateKey("interface");
                NodeSet.CreateKey("enum");
                NodeSet.CreateKey("other");
                NodeSet.CreateKey("ValueTypes");
                TreeNode node0 = new TreeNode(ns);
                node0.Tag = names;

                foreach (Type t in Types)
                {
                    if (t.IsInterface)
                    {
                        TypeGetInfo(treeView1, names, NodeSet["interface"], t);
                    }
                    else if (t.IsEnum)
                    {
                        TypeGetInfo(treeView1, names, NodeSet["enum"], t);
                    }
                    else if (t.IsValueType)
                    {
                        TreeNode tn = TypeGetInfo(treeView1, names, NodeSet["ValueTypes"], t);
                        if (tn != null)
                        {
                            tn.ImageKey = tn.SelectedImageKey = ImageKeyNames.Field;
                        }
                    }
                    else
                    {
                        TypeGetInfo(treeView1, names, NodeSet["other"], t);
                    }
                }
                if (NodeSet["interface"].Count > 0)
                {
                    foreach (TreeNode tn in NodeSet["interface"])
                    {
                        node0.Nodes.Add(tn);
                    }
                }
                else
                {
                    NodeSet.Remove("interface");
                }
                if (NodeSet["enum"].Count > 0)
                {
                    foreach (TreeNode tn in NodeSet["enum"])
                    {
                        node0.Nodes.Add(tn);
                    }
                }
                else
                {
                    NodeSet.Remove("enum");
                }
                if (NodeSet["other"].Count > 0)
                {
                    foreach (TreeNode tn in NodeSet["other"])
                    {
                        node0.Nodes.Add(tn);
                    }
                }
                else
                {
                    NodeSet.Remove("other");
                }
                if (NodeSet["ValueTypes"].Count > 0)
                {
                    foreach (TreeNode tn in NodeSet["ValueTypes"])
                    {
                        node0.Nodes.Add(tn);
                    }
                }
                else
                {
                    NodeSet.Remove("ValueTypes");
                }

                if ((ns == null) || (ns == string.Empty))
                {
                    treeView1.Nodes.Add(node0);
                }
                else
                {
                    Nodes.Add(node0);
                }
            }

            treeView1.Nodes.AddRange(Nodes.ToArray()); Nodes.Clear();
            return(asm);
        }