- Timestamp:
- 04/16/13 13:13:41 (11 years ago)
- Location:
- branches/OaaS
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/OaaS
- Property svn:ignore
-
old new 21 21 protoc.exe 22 22 _ReSharper.HeuristicLab 3.3 Tests 23 Google.ProtocolBuffers-2.4.1.473.dll 23 24 packages
-
- Property svn:mergeinfo changed
- Property svn:ignore
-
branches/OaaS/HeuristicLab.PluginInfrastructure/3.3/WebApplicationManager.cs
r8958 r9363 25 25 using System.Linq; 26 26 using System.Reflection; 27 using System.Text; 27 28 using HeuristicLab.PluginInfrastructure.Manager; 28 using System.Text;29 29 30 30 namespace HeuristicLab.PluginInfrastructure { … … 38 38 internal class WebApplicationManager : MarshalByRefObject, IApplicationManager { 39 39 // private class to store plugin dependency declarations while reflecting over plugins 40 private class PluginDependency 41 { 40 private class PluginDependency { 42 41 public string Name { get; private set; } 43 42 public Version Version { get; private set; } 44 43 45 public PluginDependency(string name, Version version) 46 { 44 public PluginDependency(string name, Version version) { 47 45 this.Name = name; 48 46 this.Version = version; … … 99 97 // the dependencies in the plugin descriptions are not yet set correctly because we need to create 100 98 // the full list of all plugin descriptions first 101 private List<PluginDescription> GatherPluginDescriptions() 102 { 99 private List<PluginDescription> GatherPluginDescriptions() { 103 100 /*List<PluginDescription> pluginDescriptions = new List<PluginDescription>(); 104 101 … … 167 164 /// </summary> 168 165 /// <param name="pluginType"></param> 169 private PluginDescription GetPluginDescription(Type pluginType) 170 { 166 private PluginDescription GetPluginDescription(Type pluginType) { 171 167 172 168 string pluginName, pluginDescription, pluginVersion; … … 180 176 if (!string.IsNullOrEmpty(pluginName) && 181 177 pluginFiles.Count() > 0 && // at least one file 182 pluginFiles.Any(f => f.Type == PluginFileType.Assembly)) 183 { // at least one assembly 178 pluginFiles.Any(f => f.Type == PluginFileType.Assembly)) { // at least one assembly 184 179 // create a temporary PluginDescription that contains the attribute values 185 180 PluginDescription info = new PluginDescription(); … … 194 189 //this.pluginDependencies[info] = pluginDependencies; 195 190 return info; 196 } 197 else 198 { 191 } else { 199 192 throw new InvalidPluginException("Invalid metadata in plugin " + pluginType.ToString()); 200 193 } 201 194 } 202 195 203 private static string ReadLicenseFiles(IEnumerable<PluginFile> pluginFiles) 204 { 196 private static string ReadLicenseFiles(IEnumerable<PluginFile> pluginFiles) { 205 197 // combine the contents of all plugin files 206 198 var licenseFiles = from file in pluginFiles … … 210 202 StringBuilder licenseTextBuilder = new StringBuilder(); 211 203 licenseTextBuilder.AppendLine(File.ReadAllText(licenseFiles.First().Name)); 212 foreach (var licenseFile in licenseFiles.Skip(1)) 213 { 204 foreach (var licenseFile in licenseFiles.Skip(1)) { 214 205 licenseTextBuilder.AppendLine().AppendLine(); // leave some empty space between multiple license files 215 206 licenseTextBuilder.AppendLine(File.ReadAllText(licenseFile.Name)); … … 218 209 } 219 210 220 private static IEnumerable<PluginDependency> GetPluginDependencyMetaData(Type pluginType) 221 { 211 private static IEnumerable<PluginDependency> GetPluginDependencyMetaData(Type pluginType) { 222 212 // get all attributes of type PluginDependency 223 213 var dependencyAttributes = from attr in CustomAttributeData.GetCustomAttributes(pluginType) … … 225 215 select attr; 226 216 227 foreach (var dependencyAttr in dependencyAttributes) 228 { 217 foreach (var dependencyAttr in dependencyAttributes) { 229 218 string name = (string)dependencyAttr.ConstructorArguments[0].Value; 230 219 Version version = new Version("0.0.0.0"); // default version … … 232 221 // later when the constructor of PluginDependencyAttribute with only one argument has been removed 233 222 // this conditional can be removed as well 234 if (dependencyAttr.ConstructorArguments.Count > 1) 235 { 236 try 237 { 223 if (dependencyAttr.ConstructorArguments.Count > 1) { 224 try { 238 225 version = new Version((string)dependencyAttr.ConstructorArguments[1].Value); // might throw FormatException 239 226 } 240 catch (FormatException ex) 241 { 227 catch (FormatException ex) { 242 228 throw new InvalidPluginException("Invalid version format of dependency " + name + " in plugin " + pluginType.ToString(), ex); 243 229 } … … 247 233 } 248 234 249 private static bool IsAttributeDataForType(CustomAttributeData attributeData, Type attributeType) 250 { 235 private static bool IsAttributeDataForType(CustomAttributeData attributeData, Type attributeType) { 251 236 return attributeData.Constructor.DeclaringType.AssemblyQualifiedName == attributeType.AssemblyQualifiedName; 252 237 } 253 238 254 private static void GetPluginContactMetaData(Type pluginType, out string contactName, out string contactAddress) 255 { 239 private static void GetPluginContactMetaData(Type pluginType, out string contactName, out string contactAddress) { 256 240 // get attribute of type ContactInformation if there is any 257 241 var contactInfoAttribute = (from attr in CustomAttributeData.GetCustomAttributes(pluginType) … … 259 243 select attr).SingleOrDefault(); 260 244 261 if (contactInfoAttribute != null) 262 { 245 if (contactInfoAttribute != null) { 263 246 contactName = (string)contactInfoAttribute.ConstructorArguments[0].Value; 264 247 contactAddress = (string)contactInfoAttribute.ConstructorArguments[1].Value; 265 } 266 else 267 { 248 } else { 268 249 contactName = string.Empty; 269 250 contactAddress = string.Empty; … … 272 253 273 254 // not static because we need the PluginDir property 274 private IEnumerable<PluginFile> GetPluginFilesMetaData(Type pluginType) 275 { 255 private IEnumerable<PluginFile> GetPluginFilesMetaData(Type pluginType) { 276 256 // get all attributes of type PluginFileAttribute 277 257 var pluginFileAttributes = from attr in CustomAttributeData.GetCustomAttributes(pluginType) 278 258 where IsAttributeDataForType(attr, typeof(PluginFileAttribute)) 279 259 select attr; 280 foreach (var pluginFileAttribute in pluginFileAttributes) 281 { 260 foreach (var pluginFileAttribute in pluginFileAttributes) { 282 261 string pluginFileName = (string)pluginFileAttribute.ConstructorArguments[0].Value; 283 262 PluginFileType fileType = (PluginFileType)pluginFileAttribute.ConstructorArguments[1].Value; … … 286 265 } 287 266 288 private static void GetPluginMetaData(Type pluginType, out string pluginName, out string pluginDescription, out string pluginVersion) 289 { 267 private static void GetPluginMetaData(Type pluginType, out string pluginName, out string pluginDescription, out string pluginVersion) { 290 268 // there must be a single attribute of type PluginAttribute 291 269 var pluginMetaDataAttr = (from attr in CustomAttributeData.GetCustomAttributes(pluginType) … … 298 276 pluginVersion = "0.0.0.0"; 299 277 pluginDescription = string.Empty; 300 if (pluginMetaDataAttr.ConstructorArguments.Count() == 2) 301 { 278 if (pluginMetaDataAttr.ConstructorArguments.Count() == 2) { 302 279 // if two arguments are given the second argument is the version 303 280 pluginVersion = (string)pluginMetaDataAttr.ConstructorArguments[1].Value; 304 } 305 else if (pluginMetaDataAttr.ConstructorArguments.Count() == 3) 306 { 281 } else if (pluginMetaDataAttr.ConstructorArguments.Count() == 3) { 307 282 // if three arguments are given the second argument is the description and the third is the version 308 283 pluginDescription = (string)pluginMetaDataAttr.ConstructorArguments[1].Value; … … 353 328 /// </summary> 354 329 /// <param name="appInfo">Description of the application to run</param> 355 internal void Run(ApplicationDescription appInfo ) {330 internal void Run(ApplicationDescription appInfo, ICommandLineArgument[] args) { 356 331 IApplication runnablePlugin = (IApplication)Activator.CreateInstance(appInfo.DeclaringAssemblyName, appInfo.DeclaringTypeName).Unwrap(); 357 332 try { 358 runnablePlugin.Run( );333 runnablePlugin.Run(args); 359 334 } 360 335 finally {
Note: See TracChangeset
for help on using the changeset viewer.