/// <summary> /// Load the build plug-ins found in the Components and Plug-Ins /// folder and its subfolders. /// </summary> private static void LoadPlugIns() { List<string> allFiles = new List<string>(); Assembly asm; Type[] types; PlugInInfo info; string shfbFolder, plugInsFolder, componentPath; plugIns = new Dictionary<string, PlugInInfo>(); asm = Assembly.GetExecutingAssembly(); shfbFolder = asm.Location; shfbFolder = shfbFolder.Substring(0, shfbFolder.LastIndexOf('\\') + 1); plugInsFolder = Path.Combine(Environment.GetFolderPath( Environment.SpecialFolder.CommonApplicationData), Constants.ComponentsAndPlugInsFolder); // Give precedence to plug-ins in the optional SHFBCOMPONENTROOT // environment variable folder. componentPath = Environment.ExpandEnvironmentVariables("%SHFBCOMPONENTROOT%"); if(!String.IsNullOrEmpty(componentPath) && Directory.Exists(componentPath)) allFiles.AddRange(Directory.GetFiles(componentPath, "*.plugins", SearchOption.AllDirectories)); // Add the standard plug-ins file and any third-party plug-in // files in the installation folder too. This allows for XCOPY // deployments of SHFB to build servers. allFiles.AddRange(Directory.GetFiles(shfbFolder, "*.plugins", SearchOption.AllDirectories)); // Finally, check the common app data build components folder if(Directory.Exists(plugInsFolder)) allFiles.AddRange(Directory.GetFiles(plugInsFolder, "*.plugins", SearchOption.AllDirectories)); foreach(string file in allFiles) { // Any exceptions that occur during the loading of a plug-in // will be handled by the caller. asm = Assembly.LoadFrom(file); types = asm.GetTypes(); foreach(Type t in types) if(t.IsPublic && !t.IsAbstract && typeof(IPlugIn).IsAssignableFrom(t)) { info = new PlugInInfo(t); if(!plugIns.ContainsKey(info.Name)) plugIns.Add(info.Name, info); } } }
/// <summary> /// Load the build plug-ins found in the Components and Plug-Ins /// folder and its subfolders. /// </summary> private static void LoadPlugIns() { List <string> allFiles = new List <string>(); Assembly asm; Type[] types; PlugInInfo info; string shfbFolder, plugInsFolder, componentPath; plugIns = new Dictionary <string, PlugInInfo>(); asm = Assembly.GetExecutingAssembly(); shfbFolder = asm.Location; shfbFolder = shfbFolder.Substring(0, shfbFolder.LastIndexOf('\\') + 1); plugInsFolder = Path.Combine(Environment.GetFolderPath( Environment.SpecialFolder.CommonApplicationData), Constants.ComponentsAndPlugInsFolder); // Give precedence to plug-ins in the optional SHFBCOMPONENTROOT // environment variable folder. componentPath = Environment.ExpandEnvironmentVariables("%SHFBCOMPONENTROOT%"); if (!String.IsNullOrEmpty(componentPath) && Directory.Exists(componentPath)) { allFiles.AddRange(Directory.GetFiles(componentPath, "*.plugins", SearchOption.AllDirectories)); } // Add the standard plug-ins file and any third-party plug-in // files in the installation folder too. This allows for XCOPY // deployments of SHFB to build servers. allFiles.AddRange(Directory.GetFiles(shfbFolder, "*.plugins", SearchOption.AllDirectories)); // Finally, check the common app data build components folder if (Directory.Exists(plugInsFolder)) { allFiles.AddRange(Directory.GetFiles(plugInsFolder, "*.plugins", SearchOption.AllDirectories)); } foreach (string file in allFiles) { // Any exceptions that occur during the loading of a plug-in // will be handled by the caller. asm = Assembly.LoadFrom(file); types = asm.GetTypes(); foreach (Type t in types) { if (t.IsPublic && !t.IsAbstract && typeof(IPlugIn).IsAssignableFrom(t)) { info = new PlugInInfo(t); if (!plugIns.ContainsKey(info.Name)) { plugIns.Add(info.Name, info); } } } } }