public void AddAssembly(Assembly a) { Type[] tps = VPLUtil.GetExportedTypes(a); for (int i = 0; i < tps.Length; i++) { if (tps[i] != null && tps[i].IsPublic) { if (string.IsNullOrEmpty(tps[i].Namespace)) { NamespaceClass nc; if (!_namespaces.TryGetValue(string.Empty, out nc)) { nc = new NamespaceClass(string.Empty); _namespaces.Add(string.Empty, nc); } nc.AddType(tps[i]); } else { NamespaceClass nc; if (!_namespaces.TryGetValue(tps[i].Namespace, out nc)) { nc = new NamespaceClass(tps[i].Namespace); _namespaces.Add(tps[i].Namespace, nc); } nc.AddType(tps[i]); } } } }
public bool ShowPublicTypes(System.Windows.Forms.ListBox lst, out string sMsg) { bool bRet = false; sMsg = ""; lst.Items.Clear(); string sCurDir = Directory.GetCurrentDirectory(); try { string sDir = Path.GetDirectoryName(sDllFile); Directory.SetCurrentDirectory(sDir); System.Reflection.Assembly a = System.Reflection.Assembly.LoadFrom(sDllFile); System.Type[] tps = VPLUtil.GetExportedTypes(a); if (tps != null) { for (int i = 0; i < tps.Length; i++) { if (tps[i].IsPublic && !tps[i].IsAbstract && tps[i].IsClass) { if (tps[i].IsSubclassOf(typeof(System.Windows.Forms.Control)) || !ControlOnly) { lst.Items.Add(tps[i]); } else { System.Type tp0 = System.Type.GetType(tps[i].AssemblyQualifiedName); if (tp0 != null) { if (tp0.IsSubclassOf(typeof(System.Windows.Forms.Control)) || !ControlOnly) { lst.Items.Add(tp0); } } } } } bRet = true; } } catch (Exception er) { sMsg = er.Message; } Directory.SetCurrentDirectory(sCurDir); return(bRet); }