Changeset 2688 for trunk/sources/HeuristicLab.PluginInfrastructure
- Timestamp:
- 01/27/10 11:11:52 (15 years ago)
- Location:
- trunk/sources/HeuristicLab.PluginInfrastructure
- Files:
-
- 2 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.PluginInfrastructure/Advanced/InstallationManager.cs
r2612 r2688 28 28 using System.ComponentModel; 29 29 using HeuristicLab.PluginInfrastructure.UpdateLocationReference; 30 using System.Reflection; 30 31 31 32 namespace HeuristicLab.PluginInfrastructure.Advanced { … … 67 68 builder.Append("Build date: ").AppendLine(desc.BuildDate.ToString()); 68 69 builder.AppendLine("Files: "); 69 foreach (string fileName in desc.Files) {70 foreach (string fileName in from file in desc.Files select file.Name) { 70 71 builder.AppendLine(fileName); 71 72 } … … 95 96 StringBuilder builder = new StringBuilder(); 96 97 var missingFiles = from x in desc.Files 97 where !File.Exists(x )98 select x ;98 where !File.Exists(x.Name) 99 select x.Name; 99 100 if (missingFiles.Count() > 0) { 100 foreach (string fileName in desc.Files) {101 foreach (string fileName in from file in desc.Files select file.Name) { 101 102 if (!File.Exists(fileName)) builder.Append("Missing file: ").AppendLine(fileName); 102 103 } … … 126 127 // or there was a problem loading the assemblies 127 128 builder.AppendLine("There was a problem while loading assemblies: "); 128 foreach ( string assembly in desc.Assemblies) {129 builder.AppendLine(assembly );129 foreach (AssemblyName assembly in desc.AssemblyNames) { 130 builder.AppendLine(assembly.FullName); 130 131 } 131 132 return builder.ToString(); … … 196 197 public void Remove(IEnumerable<string> pluginNames) { 197 198 var fileNames = from pluginToDelete in PluginDescriptionIterator.IterateDependentsTopDown(GetPluginDescriptions(pluginNames), pluginManager.Plugins) 198 from file Namein pluginToDelete.Files199 select Path.Combine(pluginDir, file Name);199 from file in pluginToDelete.Files 200 select Path.Combine(pluginDir, file.Name); 200 201 var args = new PluginInfrastructureCancelEventArgs("Deleting", fileNames); 201 202 OnPreDelete(args); -
trunk/sources/HeuristicLab.PluginInfrastructure/ApplicationManager.cs
r2686 r2688 103 103 // load all loadable plugins (all dependencies available) into the execution context 104 104 foreach (var desc in PluginDescriptionIterator.IterateDependenciesBottomUp(plugins.Where(x => x.PluginState != PluginState.Disabled))) { 105 foreach ( string assembly in desc.Assemblies) {106 var asm = Assembly.Load From(assembly);105 foreach (AssemblyName assemblyName in desc.AssemblyNames) { 106 var asm = Assembly.Load(assemblyName); 107 107 108 108 // instantiate and load all plugins in this assembly … … 213 213 PluginDescription pluginDesc = (PluginDescription)pluginDescription; 214 214 return from asm in AppDomain.CurrentDomain.GetAssemblies() 215 where !string.IsNullOrEmpty(asm.Location) && 216 pluginDesc.Assemblies.Any(asmPath => 217 Path.GetFullPath(asmPath).Equals(Path.GetFullPath(asm.Location), 218 StringComparison.CurrentCultureIgnoreCase)) 215 where pluginDesc.AssemblyNames.Any(asmName => asmName.FullName.Equals(asm.GetName().FullName)) 219 216 from t in GetTypes(type, asm, onlyInstantiable) 220 217 select t; … … 286 283 public IPluginDescription GetDeclaringPlugin(Type type) { 287 284 foreach (PluginDescription info in Plugins) { 288 if (info.Assembl ies.Contains(Path.GetFullPath(type.Assembly.Location))) return info;285 if (info.AssemblyNames.Contains(type.Assembly.GetName())) return info; 289 286 } 290 287 return null; -
trunk/sources/HeuristicLab.PluginInfrastructure/HeuristicLab.PluginInfrastructure.csproj
r2600 r2688 101 101 <Compile Include="BaseClasses\ApplicationBase.cs" /> 102 102 <Compile Include="BaseClasses\PluginBase.cs" /> 103 <Compile Include="Interfaces\IPluginFile.cs" /> 103 104 <Compile Include="Interfaces\IApplicationManager.cs" /> 104 105 <Compile Include="Interfaces\IApplicationDescription.cs" /> … … 110 111 <Compile Include="InvalidPluginException.cs" /> 111 112 <Compile Include="Manager\ApplicationDescription.cs" /> 113 <Compile Include="Manager\PluginFile.cs" /> 112 114 <Compile Include="Manager\PluginInfrastructureCancelEventArgs.cs" /> 113 115 <Compile Include="Manager\PluginDescription.cs" /> -
trunk/sources/HeuristicLab.PluginInfrastructure/Interfaces/IPluginDescription.cs
r2666 r2688 47 47 /// Gets the file names of files that are part of the plugin. 48 48 /// </summary> 49 IEnumerable<string> Files { get; } 50 51 /// <summary> 52 /// Get a list of assembly names associated with the plugin. 53 /// </summary> 54 IEnumerable<string> Assemblies { get; } 49 IEnumerable<IPluginFile> Files { get; } 55 50 } 56 51 } -
trunk/sources/HeuristicLab.PluginInfrastructure/Manager/PluginDescription.cs
r2666 r2688 24 24 using System.Text; 25 25 using System.Linq; 26 using System.Reflection; 26 27 27 28 namespace HeuristicLab.PluginInfrastructure.Manager { … … 77 78 78 79 79 private List< string> files = new List<string>();80 private List<PluginFile> files = new List<PluginFile>(); 80 81 /// <summary> 81 82 /// Gets the names of all files that belong to this plugin. 82 83 /// These files are deleted when the plugin is removed or updated. 83 84 /// </summary> 84 public IEnumerable< string> Files {85 get { return files ; }85 public IEnumerable<IPluginFile> Files { 86 get { return files.Cast<IPluginFile>(); } 86 87 } 87 88 88 internal void AddFiles(IEnumerable< string> fileNames) {89 internal void AddFiles(IEnumerable<PluginFile> fileNames) { 89 90 files.AddRange(fileNames); 90 91 } … … 105 106 } 106 107 107 private List< string> assemblies = new List<string>();108 private List<AssemblyName> assemblyNames = new List<AssemblyName>(); 108 109 /// <summary> 109 110 /// Gets the names of the assemblies that belong to this plugin. 110 111 /// </summary> 111 public IEnumerable<string> Assemblies { 112 get { return assemblies; } 113 // set { assemblies = value; } 112 public IEnumerable<AssemblyName> AssemblyNames { 113 get { return assemblyNames; } 114 114 } 115 115 116 internal void AddAssembl ies(IEnumerable<string> assemblyNames) {117 assemblies.AddRange(assemblyNames);116 internal void AddAssemblyNames(IEnumerable<AssemblyName> assemblyNames) { 117 this.assemblyNames.AddRange(assemblyNames); 118 118 } 119 119 -
trunk/sources/HeuristicLab.PluginInfrastructure/Manager/PluginValidator.cs
r2648 r2688 172 172 foreach (var desc in pluginDescriptions.Where(x => x.PluginState != PluginState.Disabled)) { 173 173 try { 174 foreach (var asm in desc.Assemblies) {175 Assembly.ReflectionOnlyLoad From(asm);174 foreach (var asmName in desc.AssemblyNames) { 175 Assembly.ReflectionOnlyLoad(asmName.FullName); 176 176 } 177 177 } … … 237 237 // get all attributes of that type 238 238 IList<CustomAttributeData> attributes = CustomAttributeData.GetCustomAttributes(pluginType); 239 List< string> pluginAssemblies = new List<string>();239 List<AssemblyName> pluginAssemblyNames = new List<AssemblyName>(); 240 240 List<string> pluginDependencies = new List<string>(); 241 List< string> pluginFiles = new List<string>();241 List<PluginFile> pluginFiles = new List<PluginFile>(); 242 242 string pluginName = null; 243 243 string pluginDescription = null; … … 254 254 string pluginFileName = (string)attributeData.ConstructorArguments[0].Value; 255 255 PluginFileType fileType = (PluginFileType)attributeData.ConstructorArguments[1].Value; 256 pluginFiles.Add( Path.GetFullPath(Path.Combine(PluginDir, pluginFileName)));256 pluginFiles.Add(new PluginFile(Path.GetFullPath(Path.Combine(PluginDir, pluginFileName)), fileType)); 257 257 if (fileType == PluginFileType.Assembly) { 258 pluginAssembl ies.Add(Path.GetFullPath(Path.Combine(PluginDir, pluginFileName)));258 pluginAssemblyNames.Add(AssemblyName.GetAssemblyName(Path.GetFullPath(Path.Combine(PluginDir, pluginFileName)))); 259 259 } 260 260 } … … 268 268 if (!string.IsNullOrEmpty(pluginName) && 269 269 pluginFiles.Count > 0 && 270 pluginAssembl ies.Count > 0 &&270 pluginAssemblyNames.Count > 0 && 271 271 buildDates.Count() == 1) { 272 272 // create a temporary PluginDescription that contains the attribute values … … 276 276 info.Version = pluginType.Assembly.GetName().Version; 277 277 info.BuildDate = DateTime.Parse(buildDates.Single(), System.Globalization.CultureInfo.InvariantCulture); 278 info.AddAssembl ies(pluginAssemblies);278 info.AddAssemblyNames(pluginAssemblyNames); 279 279 info.AddFiles(pluginFiles); 280 280 … … 349 349 .Where(x => x.PluginState != PluginState.Disabled))) { 350 350 List<Type> types = new List<Type>(); 351 foreach ( string assembly in desc.Assemblies) {352 var asm = Assembly.Load From(assembly);351 foreach (AssemblyName assemblyName in desc.AssemblyNames) { 352 var asm = Assembly.Load(assemblyName); 353 353 foreach (Type t in asm.GetTypes()) { 354 354 if (typeof(IPlugin).IsAssignableFrom(t)) { … … 379 379 380 380 private bool CheckPluginFiles(PluginDescription pluginDescription) { 381 foreach (string filename in pluginDescription.Files ) {381 foreach (string filename in pluginDescription.Files.Select(x => x.Name)) { 382 382 if (!FileLiesInDirectory(PluginDir, filename) || 383 383 !File.Exists(filename)) {
Note: See TracChangeset
for help on using the changeset viewer.