private void LoadPluginInfo() { if (!Directory.Exists(_pluginDir)) { throw new PluginException(SR.ExceptionPluginDirectoryNotFound); } _plugins.AddRange(_loader.LoadPluginInfo()); // If no plugins were loaded, nothing else to do if (_plugins.Count == 0) { return; } // compile lists of all extension points and extensions var extensions = new List <ExtensionInfo>(_plugins.SelectMany(p => p.Extensions)); var points = new List <ExtensionPointInfo>(_plugins.SelectMany(p => p.ExtensionPoints)); // hack: add points and extensions from ClearCanvas.Common, which isn't technically a plugin PluginInfo.DiscoverExtensionPointsAndExtensions(GetType().Assembly, points, extensions); // #742: order the extensions according to the XML configuration var ordered = ExtensionSettings.Default.OrderExtensions(extensions); // create global extension list _extensions.AddRange(ordered); // points do not need to be ordered _extensionPoints.AddRange(points); _pluginsLoaded = true; }
/// <summary> /// Loads all plugins in the current plugin directory. /// </summary> /// <remarks> /// This method will traverse the plugin directory and all its subdirectories loading /// all valid plugin assemblies. A valid plugin is an assembly that is marked with an assembly /// attribute of type <see cref="ClearCanvas.Common.PluginAttribute"/>. /// </remarks> /// <exception cref="PluginException">Specified plugin directory does not exist.</exception> private void LoadPlugins() { if (!Directory.Exists(_pluginDir)) { throw new PluginException(SR.ExceptionPluginDirectoryNotFound); } EventsHelper.Fire(_pluginProgressEvent, this, new PluginLoadedEventArgs(SR.MessageFindingPlugins, null)); // Process the plugin directory FileProcessor.Process(_pluginDir, "*.dll", LoadPlugin, true); // If no plugins were loaded, nothing else to do if (_plugins.Count == 0) { return; } // compile lists of all extension points and extensions var extensions = new List <ExtensionInfo>(_plugins.SelectMany(p => p.Extensions)); var points = new List <ExtensionPointInfo>(_plugins.SelectMany(p => p.ExtensionPoints)); // hack: add points and extensions from ClearCanvas.Common, which isn't technically a plugin PluginInfo.DiscoverExtensionPointsAndExtensions(GetType().Assembly, points, extensions); // #742: order the extensions according to the XML configuration List <ExtensionInfo> ordered, remainder; ExtensionSettings.Default.OrderExtensions(extensions, out ordered, out remainder); // create global extension list, with the ordered set appearing first _extensions.AddRange(CollectionUtils.Concat <ExtensionInfo>(ordered, remainder)); // points do not need to be ordered _extensionPoints.AddRange(points); _pluginsLoaded = true; }