private void LoadAssembly() { string InstallFolder = GeneralOptions.Instance.Path;; if (!Directory.Exists(InstallFolder)) { OutputWindowManager outPutWindowmng = new OutputWindowManager(); StringBuilder msg = new StringBuilder(); msg.Append("Could not find PRIMAVERA installation folder {0}.\n"); msg.Append("Check configuration on visual studio options."); outPutWindowmng.WriteMessage(msg.ToString(), OutputWindowMessagesType.Error); throw new DirectoryNotFoundException(String.Format(msg.ToString(), InstallFolder)); } IEnumerable <string> folder = Directory.EnumerateFiles(InstallFolder, "*.dll"); foreach (string file in folder) { string fileName = Path.GetFileNameWithoutExtension(file); if (fileName.ToLower().StartsWith("primavera.extensibility") && !fileName.ToLower().EndsWith("attributes") && !fileName.ToLower().EndsWith("businessentities") && !fileName.ToLower().EndsWith("constants") && !fileName.ToLower().EndsWith("customcode") && !fileName.ToLower().EndsWith("customform") && !fileName.ToLower().EndsWith("customtab") && !fileName.ToLower().EndsWith("engine") && !fileName.ToLower().EndsWith("extensions") && !fileName.ToLower().EndsWith("integration") && !fileName.ToLower().EndsWith("patterns")) { // Build the root nodes collection TreeNode parent = trw.Nodes.Add(fileName.Remove(0, 24)); } } }
private void LoadAssembly() { string InstallFolder = GeneralOptions.Instance.Path;; if (!Directory.Exists(InstallFolder)) { OutputWindowManager outPutWindowmng = new OutputWindowManager(); StringBuilder msg = new StringBuilder(); msg.Append("Could not find PRIMAVERA installation folder {0}.\n"); msg.Append("Check configuration on visual studio options."); outPutWindowmng.WriteMessage(msg.ToString(), OutputWindowMessagesType.Error); throw new DirectoryNotFoundException(String.Format(msg.ToString(), InstallFolder)); } IEnumerable <string> folder = Directory.EnumerateFiles(InstallFolder, "*.dll"); foreach (string file in folder) { string fileName = Path.GetFileNameWithoutExtension(file); if (fileName.ToLower().StartsWith("primavera.extensibility") && !fileName.ToLower().EndsWith("attributes") && !fileName.ToLower().EndsWith("businessentities") && !fileName.ToLower().EndsWith("constants") && !fileName.ToLower().EndsWith("customcode") && !fileName.ToLower().EndsWith("customform") && !fileName.ToLower().EndsWith("customtab") && !fileName.ToLower().EndsWith("engine") && !fileName.ToLower().EndsWith("extensions") && !fileName.ToLower().EndsWith("integration") && !fileName.ToLower().EndsWith("patterns")) { string moduleRootnode = fileName.Remove(0, 24); // Build the root nodes collection rootNodes.Add(new MyTreeNode() { Text = moduleRootnode }); // MEF load assemblies Assembly assembly = Assembly.LoadFrom(file); // Build the child nodes collection foreach (var exportedType in assembly.GetExportedTypes()) { MyTreeNode node = null; string[] namespaceParts = exportedType.Namespace.Split('.'); if (namespaceParts.Length == 4) { node = new MyTreeNode() { Module = namespaceParts[2], ModuleType = namespaceParts[3], ClassName = exportedType.Name, Text = exportedType.Name, ParentNode = moduleRootnode, Namespace = exportedType.Namespace }; } childNodes.Add(node); } } } }