Changeset 2495 for branches/PluginInfrastructure Refactoring/HeuristicLab.PluginInfrastructure.Manager
- Timestamp:
- 11/16/09 14:25:50 (15 years ago)
- Location:
- branches/PluginInfrastructure Refactoring/HeuristicLab.PluginInfrastructure.Manager
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/PluginInfrastructure Refactoring/HeuristicLab.PluginInfrastructure.Manager/ApplicationManager.cs
r2489 r2495 28 28 using System.Security; 29 29 using System.Linq; 30 using System.IO; 30 31 31 32 namespace HeuristicLab.PluginInfrastructure.Manager { … … 75 76 // load all loadable plugins (all dependencies available) into the execution context 76 77 foreach (var desc in PluginDescriptionIterator.IterateInDependencyOrder(plugins.Where(x => x.PluginState != PluginState.Disabled))) { 77 foreach (var plugin in GetInstances<IPlugin>(desc)) { 78 plugin.OnLoad(); 79 FirePluginLoaded(plugin.Name); 78 foreach (string assembly in desc.Assemblies) { 79 var asm = Assembly.LoadFrom(assembly); 80 81 // instantiate and load all plugins in this assembly 82 foreach (var plugin in GetInstances<IPlugin>(asm)) { 83 plugin.OnLoad(); 84 FirePluginLoaded(plugin.Name); 85 } 80 86 } 81 87 desc.Load(); 82 88 } 89 83 90 } 84 91 … … 128 135 } 129 136 /// <summary> 137 /// Creates an instance of all types declared in assembly <param name="asm"/> that are subtypes or the same type of the specified type and declared in <paramref name="plugin"/> 138 /// </summary> 139 /// <typeparam name="T">Most general type.</typeparam> 140 /// <param name="asm">Declaring assembly.</param> 141 /// <returns>Enumerable of the created instances.</returns> 142 public IEnumerable<T> GetInstances<T>(Assembly asm) where T : class { 143 return from t in GetTypes(typeof(T), asm) 144 where !t.IsAbstract && !t.IsInterface && !t.HasElementType 145 select (T)Activator.CreateInstance(t); 146 } 147 /// <summary> 130 148 /// Creates an instance of all types that are subtypes or the same type of the specified type 131 149 /// </summary> … … 167 185 /// <returns>Enumerable of the discovered types.</returns> 168 186 public IEnumerable<Type> GetTypes(Type type, IPluginDescription pluginDescription) { 169 throw new NotImplementedException(); 170 //return from asm in AppDomain.CurrentDomain.GetAssemblies() 171 // where pluginDescription.Assemblies.Contains(asm.Location) 172 // from t in GetTypes(type, asm) 173 // select t; 187 return from asm in AppDomain.CurrentDomain.GetAssemblies() 188 where pluginDescription.Assemblies.Any(asmPath => Path.GetFullPath(asmPath) == Path.GetFullPath(asm.Location)) 189 from t in GetTypes(type, asm) 190 select t; 174 191 } 175 192 -
branches/PluginInfrastructure Refactoring/HeuristicLab.PluginInfrastructure.Manager/Loader.cs
r2489 r2495 195 195 string pluginFileName = (string)attributeData.ConstructorArguments[0].Value; 196 196 PluginFileType fileType = (PluginFileType)attributeData.ConstructorArguments[1].Value; 197 pluginFiles.Add(P luginDir + "/" + pluginFileName);197 pluginFiles.Add(Path.Combine(PluginDir, pluginFileName)); 198 198 if (fileType == PluginFileType.Assembly) { 199 pluginAssemblies.Add(P luginDir + "/" + pluginFileName);199 pluginAssemblies.Add(Path.Combine(PluginDir, pluginFileName)); 200 200 } 201 201 }
Note: See TracChangeset
for help on using the changeset viewer.