Changeset 37 for trunk/sources/HeuristicLab.PluginInfrastructure
- Timestamp:
- 03/04/08 15:16:51 (17 years ago)
- Location:
- trunk/sources/HeuristicLab.PluginInfrastructure
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.PluginInfrastructure/Loader.cs
r29 r37 75 75 76 76 private IPlugin FindPlugin(PluginInfo plugin) { 77 return allPlugins[plugin]; 77 if(allPlugins.ContainsKey(plugin)) { 78 return allPlugins[plugin]; 79 } else return null; 78 80 } 79 81 … … 90 92 /// </summary> 91 93 internal void Init() { 92 AppDomain.CurrentDomain.ReflectionOnlyAssemblyResolve += delegate(object sender, ResolveEventArgs args) { return Assembly.ReflectionOnlyLoad(args.Name); }; 94 AppDomain.CurrentDomain.ReflectionOnlyAssemblyResolve += delegate(object sender, ResolveEventArgs args) { 95 try { 96 return Assembly.ReflectionOnlyLoad(args.Name); 97 } catch(FileLoadException ex) { 98 return null; 99 } 100 }; 93 101 allPlugins.Clear(); 94 102 disabledPlugins.Clear(); … … 150 158 } 151 159 } 152 } catch(FileNotFoundException) { 153 // when a referenced assembly cannot be loaded then ignore this assembly in the plugin discovery 160 } catch(FileNotFoundException ex) { 161 PluginInfo info = new PluginInfo(); 162 AssemblyName name = assembly.GetName(); 163 info.Name = name.Name; 164 info.Version = name.Version; 165 info.Assemblies.Add(assembly.FullName); 166 info.Files.Add(assembly.Location); 167 info.Message = "File not found: " + ex.FileName; 168 disabledPlugins.Add(info); 169 } catch(FileLoadException ex) { 170 PluginInfo info = new PluginInfo(); 171 AssemblyName name = assembly.GetName(); 172 info.Name = name.Name; 173 info.Version = name.Version; 174 info.Files.Add(assembly.Location); 175 info.Assemblies.Add(assembly.FullName); 176 info.Message = "Couldn't load file: " + ex.FileName; 177 disabledPlugins.Add(info); 154 178 } 155 179 } … … 208 232 PluginInfo info = new PluginInfo(); 209 233 info.Name = pluginName; 234 info.Version = t.Assembly.GetName().Version; 210 235 info.Assemblies = pluginAssemblies; 211 236 info.Files.AddRange(pluginFiles); … … 226 251 visitedDependencies.Clear(); 227 252 if(!CheckPluginDependencies(pluginInfo.Name)) { 253 PluginInfo matchingInfo = preloadedPluginInfos.Find(delegate(PluginInfo info) { return info.Name == pluginInfo.Name; }); 254 if(matchingInfo == null) throw new InvalidProgramException(); // shouldn't happen 255 foreach(string dependency in pluginDependencies[matchingInfo]) { 256 PluginInfo dependencyInfo = new PluginInfo(); 257 dependencyInfo.Name = dependency; 258 pluginInfo.Dependencies.Add(dependencyInfo); 259 } 260 261 pluginInfo.Message = "Disabled: missing plugin dependency."; 228 262 disabledPlugins.Add(pluginInfo); 229 263 } … … 325 359 foreach(PluginInfo plugin in preloadedPluginInfos) { 326 360 if(!CheckPluginFiles(plugin)) { 361 plugin.Message = "Disabled: missing plugin file."; 327 362 disabledPlugins.Add(plugin); 328 363 } … … 348 383 349 384 internal void OnDelete(PluginInfo pluginInfo) { 350 FindPlugin(pluginInfo).OnDelete(); 385 IPlugin plugin = FindPlugin(pluginInfo); 386 if(plugin!=null) plugin.OnDelete(); 351 387 } 352 388 353 389 internal void OnInstall(PluginInfo pluginInfo) { 354 FindPlugin(pluginInfo).OnInstall(); 390 IPlugin plugin = FindPlugin(pluginInfo); 391 if(plugin != null) plugin.OnInstall(); 355 392 } 356 393 357 394 internal void OnPreUpdate(PluginInfo pluginInfo) { 358 FindPlugin(pluginInfo).OnPreUpdate(); 395 IPlugin plugin = FindPlugin(pluginInfo); 396 if(plugin != null) plugin.OnPreUpdate(); 359 397 } 360 398 361 399 internal void OnPostUpdate(PluginInfo pluginInfo) { 362 FindPlugin(pluginInfo).OnPostUpdate(); 400 IPlugin plugin = FindPlugin(pluginInfo); 401 if(plugin != null) plugin.OnPostUpdate(); 363 402 } 364 403 } -
trunk/sources/HeuristicLab.PluginInfrastructure/PluginInfo.cs
r29 r37 68 68 } 69 69 70 71 private string message; 72 public string Message { 73 get { return message; } 74 set { message = value; } 75 } 76 70 77 public override string ToString() { 71 78 return Name;
Note: See TracChangeset
for help on using the changeset viewer.