Changeset 2168 for trunk/sources/HeuristicLab.PluginInfrastructure
- Timestamp:
- 07/18/09 00:59:56 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.PluginInfrastructure/Loader.cs
r1897 r2168 325 325 } 326 326 327 Queue<IPlugin> pluginsToLoad = new Queue<IPlugin>(); 327 328 DiscoveryService service = new DiscoveryService(); 328 329 // now search and instantiate an IPlugin type in each loaded assembly 330 // and prepare the queue to load all plugins 329 331 foreach (Assembly assembly in AppDomain.CurrentDomain.GetAssemblies()) { 330 332 // don't search for plugins in the PluginInfrastructure … … 335 337 if (!pluginType.IsAbstract && !pluginType.IsInterface && !pluginType.HasElementType) { 336 338 IPlugin plugin = (IPlugin)Activator.CreateInstance(pluginType); 337 PluginAction(this, new PluginManagerActionEventArgs(plugin.Name, PluginManagerAction.InitializingPlugin)); 338 plugin.OnLoad(); 339 pluginsToLoad.Enqueue(plugin); 339 340 pluginsByName.Add(plugin.Name, plugin); 340 341 } … … 342 343 } 343 344 344 foreach (IPlugin plugin in pluginsByName.Values) { 345 // load all plugins respecting their dependencies 346 while (pluginsToLoad.Count > 0) { 347 IPlugin plugin = pluginsToLoad.Dequeue(); 345 348 PluginInfo pluginInfo = GetPluginInfo(plugin); 346 allPlugins.Add(pluginInfo, plugin); 347 PluginAction(this, new PluginManagerActionEventArgs(plugin.Name, PluginManagerAction.InitializedPlugin)); 349 bool canLoad = true; 350 foreach (PluginInfo dependency in pluginInfo.Dependencies) { 351 if (!allPlugins.ContainsKey(dependency)) { 352 canLoad = false; 353 break; 354 } 355 } 356 if (canLoad) { 357 PluginAction(this, new PluginManagerActionEventArgs(plugin.Name, PluginManagerAction.InitializingPlugin)); 358 plugin.OnLoad(); 359 allPlugins.Add(pluginInfo, plugin); 360 PluginAction(this, new PluginManagerActionEventArgs(plugin.Name, PluginManagerAction.InitializedPlugin)); 361 } else { 362 pluginsToLoad.Enqueue(plugin); 363 } 348 364 } 349 365 }
Note: See TracChangeset
for help on using the changeset viewer.