Changeset 9363 for branches/OaaS/HeuristicLab.PluginInfrastructure
- Timestamp:
- 04/16/13 13:13:41 (12 years ago)
- Location:
- branches/OaaS
- Files:
-
- 17 edited
- 2 copied
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/Advanced/DeploymentService/DeploymentServerCertificateValidator.cs
r4068 r9363 1 using System; 1 #region License Information 2 /* HeuristicLab 3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 * 5 * This file is part of HeuristicLab. 6 * 7 * HeuristicLab is free software: you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License as published by 9 * the Free Software Foundation, either version 3 of the License, or 10 * (at your option) any later version. 11 * 12 * HeuristicLab is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>. 19 */ 20 #endregion 21 22 using System; 2 23 using System.IdentityModel.Selectors; 3 24 using System.IdentityModel.Tokens; -
branches/OaaS/HeuristicLab.PluginInfrastructure/3.3/BaseClasses/ApplicationBase.cs
r7259 r9363 67 67 /// Runs the application. 68 68 /// </summary> 69 public abstract void Run( );69 public abstract void Run(ICommandLineArgument[] args); 70 70 71 71 #endregion -
branches/OaaS/HeuristicLab.PluginInfrastructure/3.3/ErrorHandling/ErrorHandling.cs
r7259 r9363 21 21 22 22 using System; 23 using System.Diagnostics; 23 24 using System.Windows.Forms; 24 25 … … 29 30 return string.Empty; 30 31 } else { 31 string message = exception.GetType().Name + ": " + exception.Message + Environment.NewLine + 32 string message = 33 "HeuristicLab version: " + FileVersionInfo.GetVersionInfo(typeof(ErrorHandling).Assembly.Location).FileVersion + Environment.NewLine + 34 exception.GetType().Name + ": " + exception.Message + Environment.NewLine + 32 35 exception.StackTrace; 33 36 -
branches/OaaS/HeuristicLab.PluginInfrastructure/3.3/ErrorHandling/FrameworkVersionErrorDialog.Designer.cs
r7967 r9363 49 49 this.linkLabel = new System.Windows.Forms.LinkLabel(); 50 50 this.label = new System.Windows.Forms.Label(); 51 this.linkLabelMono = new System.Windows.Forms.LinkLabel(); 51 52 this.SuspendLayout(); 52 53 // 53 54 // iconLabel 54 55 // 55 this.iconLabel.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 56 56 this.iconLabel.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 57 | System.Windows.Forms.AnchorStyles.Left))); 57 58 this.iconLabel.Image = global::HeuristicLab.PluginInfrastructure.Resources.Error; 58 59 this.iconLabel.ImageAlign = System.Drawing.ContentAlignment.TopLeft; 59 60 this.iconLabel.Location = new System.Drawing.Point(12, 9); 60 61 this.iconLabel.Name = "iconLabel"; 61 this.iconLabel.Size = new System.Drawing.Size(50, 98);62 this.iconLabel.Size = new System.Drawing.Size(50, 121); 62 63 this.iconLabel.TabIndex = 0; 63 64 // … … 66 67 this.closeButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); 67 68 this.closeButton.DialogResult = System.Windows.Forms.DialogResult.OK; 68 this.closeButton.Location = new System.Drawing.Point(294, 81);69 this.closeButton.Location = new System.Drawing.Point(294, 104); 69 70 this.closeButton.Name = "closeButton"; 70 71 this.closeButton.Size = new System.Drawing.Size(75, 23); … … 76 77 // linkLabel 77 78 // 78 this.linkLabel.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 79 | System.Windows.Forms.AnchorStyles.Left)80 79 this.linkLabel.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 80 | System.Windows.Forms.AnchorStyles.Left) 81 | System.Windows.Forms.AnchorStyles.Right))); 81 82 this.linkLabel.Location = new System.Drawing.Point(68, 52); 82 83 this.linkLabel.Name = "linkLabel"; 83 this.linkLabel.Size = new System.Drawing.Size(301, 26);84 this.linkLabel.Size = new System.Drawing.Size(301, 49); 84 85 this.linkLabel.TabIndex = 2; 85 86 this.linkLabel.TabStop = true; … … 89 90 // label 90 91 // 91 this.label.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 92 92 this.label.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 93 | System.Windows.Forms.AnchorStyles.Right))); 93 94 this.label.Location = new System.Drawing.Point(68, 9); 94 95 this.label.Name = "label"; 95 96 this.label.Size = new System.Drawing.Size(301, 43); 96 97 this.label.TabIndex = 1; 97 this.label.Text = "The Microsoft .NET Framework 4 (Full Profile) is not properly installed on your s" + 98 "ystem. Please download and install it."; 98 this.label.Text = "To run HeuristicLab you need at least the Microsoft .NET Framework 4 (Full Profil" + 99 "e) or Mono version 2.11.4 or higher. Please download and install it."; 100 // 101 // linkLabelMono 102 // 103 this.linkLabelMono.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 104 | System.Windows.Forms.AnchorStyles.Left) 105 | System.Windows.Forms.AnchorStyles.Right))); 106 this.linkLabelMono.Location = new System.Drawing.Point(68, 72); 107 this.linkLabelMono.Name = "linkLabelMono"; 108 this.linkLabelMono.Size = new System.Drawing.Size(301, 16); 109 this.linkLabelMono.TabIndex = 4; 110 this.linkLabelMono.TabStop = true; 111 this.linkLabelMono.Text = "Download Mono"; 112 this.linkLabelMono.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.linkLabelMono_LinkClicked); 99 113 // 100 114 // FrameworkVersionErrorDialog 101 115 // 102 116 this.AcceptButton = this.closeButton; 103 this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);104 117 this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit; 105 118 this.CancelButton = this.closeButton; 106 this.ClientSize = new System.Drawing.Size(381, 116); 119 this.ClientSize = new System.Drawing.Size(381, 139); 120 this.Controls.Add(this.linkLabelMono); 107 121 this.Controls.Add(this.label); 108 122 this.Controls.Add(this.linkLabel); … … 127 141 private System.Windows.Forms.LinkLabel linkLabel; 128 142 private System.Windows.Forms.Label label; 143 private System.Windows.Forms.LinkLabel linkLabelMono; 129 144 } 130 145 } -
branches/OaaS/HeuristicLab.PluginInfrastructure/3.3/ErrorHandling/FrameworkVersionErrorDialog.cs
r7259 r9363 8 8 * it under the terms of the GNU General Public License as published by 9 9 * the Free Software Foundation, either version 3 of the License, or 10 11 12 13 14 15 16 17 18 19 10 * (at your option) any later version. 11 * 12 * HeuristicLab is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>. 19 */ 20 20 #endregion 21 21 22 22 using System; 23 using System.Reflection; 23 24 using System.Windows.Forms; 24 25 … … 26 27 public partial class FrameworkVersionErrorDialog : Form { 27 28 public static bool NET4FullProfileInstalled { 28 get { return Microsoft.Win32.Registry.LocalMachine.OpenSubKey("Software\\Microsoft\\NET Framework Setup\\NDP\\v4\\Full") != null; } 29 get { 30 try { 31 return Microsoft.Win32.Registry.LocalMachine.OpenSubKey("Software\\Microsoft\\NET Framework Setup\\NDP\\v4\\Full") != null; 32 } 33 catch (System.Security.SecurityException) { 34 return false; 35 } 36 } 37 } 38 39 public static bool MonoInstalled { 40 get { return Type.GetType("Mono.Runtime") != null; } 41 } 42 43 public static bool MonoCorrectVersionInstalled { 44 get { 45 var monoVersion = MonoVersion; 46 var minRequiredVersion = new Version(2, 11, 4); 47 48 //we need at least mono version 2.11.4 49 if (monoVersion != null && monoVersion >= minRequiredVersion) { 50 return true; 51 } else { 52 return false; 53 } 54 } 55 } 56 57 public static Version MonoVersion { 58 get { 59 Type type = Type.GetType("Mono.Runtime"); 60 if (type != null) { 61 MethodInfo dispalayName = type.GetMethod("GetDisplayName", BindingFlags.NonPublic | BindingFlags.Static); 62 if (dispalayName != null) { 63 string versionString = dispalayName.Invoke(null, null) as string; 64 if (versionString != null) { 65 // the version string looks something like: 2.11.4 (master/99d5e54 Thu Sep 6 15:55:44 CEST 2012) 66 var subVerStrings = versionString.Split(' '); 67 if (subVerStrings.Length > 0) { 68 try { 69 return Version.Parse(subVerStrings[0]); 70 } 71 catch { } 72 } 73 } 74 } 75 } 76 return null; 77 } 29 78 } 30 79 … … 44 93 Application.Exit(); 45 94 } 95 96 private void linkLabelMono_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { 97 try { 98 System.Diagnostics.Process.Start("http://www.mono-project.org"); 99 linkLabelMono.LinkVisited = true; 100 } 101 catch (Exception) { } 102 } 46 103 } 47 104 } -
branches/OaaS/HeuristicLab.PluginInfrastructure/3.3/HeuristicLab.PluginInfrastructure-3.3.csproj
r8506 r9363 102 102 </PropertyGroup> 103 103 <ItemGroup> 104 <Reference Include="ICSharpCode.SharpZipLib, Version=0.85.4.369, Culture=neutral, PublicKeyToken=1b03e6acf1164f73, processorArchitecture=MSIL">105 <Private>False</Private>106 </Reference>107 104 <Reference Include="System" /> 108 <Reference Include="System.Core"> 109 <RequiredTargetFramework>3.5</RequiredTargetFramework> 110 </Reference> 105 <Reference Include="System.Core" /> 111 106 <Reference Include="System.Data" /> 112 107 <Reference Include="System.Deployment" /> 113 108 <Reference Include="System.Drawing" /> 114 <Reference Include="System.IdentityModel"> 115 <RequiredTargetFramework>3.0</RequiredTargetFramework> 116 </Reference> 117 <Reference Include="System.Runtime.Serialization"> 118 <RequiredTargetFramework>3.0</RequiredTargetFramework> 119 </Reference> 120 <Reference Include="System.ServiceModel"> 121 <RequiredTargetFramework>3.0</RequiredTargetFramework> 122 </Reference> 109 <Reference Include="System.IdentityModel" /> 110 <Reference Include="System.Runtime.Serialization" /> 111 <Reference Include="System.ServiceModel" /> 123 112 <Reference Include="System.Windows.Forms" /> 124 113 <Reference Include="System.Xml" /> 114 <Reference Include="ICSharpCode.SharpZipLib"> 115 <HintPath>ICSharpCode.SharpZipLib.dll</HintPath> 116 </Reference> 125 117 </ItemGroup> 126 118 <ItemGroup> … … 223 215 <DependentUpon>PluginView.cs</DependentUpon> 224 216 </Compile> 217 <Compile Include="CommandLineArgumentHandling\Arguments\OpenArgument.cs" /> 218 <Compile Include="CommandLineArgumentHandling\Arguments\HideStarterArgument.cs" /> 219 <Compile Include="CommandLineArgumentHandling\Arguments\StartArgument.cs" /> 220 <Compile Include="CommandLineArgumentHandling\CommandLineArgument.cs" /> 221 <Compile Include="CommandLineArgumentHandling\CommandLineArgumentHandling.cs" /> 222 <Compile Include="CommandLineArgumentHandling\ICommandLineArgument.cs" /> 225 223 <Compile Include="Attributes\ApplicationAttribute.cs" /> 226 224 <Compile Include="Attributes\ContactInformationAttribute.cs" /> … … 270 268 <Compile Include="Main.cs" /> 271 269 <Compile Include="Properties\AssemblyInfo.cs" /> 270 <Compile Include="TypeExtensions.cs" /> 272 271 <None Include="Advanced\DeploymentService\GenerateServiceClients.cmd" /> 273 272 <None Include="app.config"> … … 374 373 --> 375 374 <PropertyGroup> 376 <PreBuildEvent >set Path=%25Path%25;$(ProjectDir);$(SolutionDir)375 <PreBuildEvent Condition=" '$(OS)' == 'Windows_NT' ">set Path=%25Path%25;$(ProjectDir);$(SolutionDir) 377 376 set ProjectDir=$(ProjectDir) 378 377 set SolutionDir=$(SolutionDir) … … 380 379 381 380 call PreBuildEvent.cmd</PreBuildEvent> 381 <PreBuildEvent Condition=" '$(OS)' != 'Windows_NT' "> 382 export ProjectDir=$(ProjectDir) 383 export SolutionDir=$(SolutionDir) 384 385 $SolutionDir/PreBuildEvent.sh 386 </PreBuildEvent> 382 387 </PropertyGroup> 383 388 </Project> -
branches/OaaS/HeuristicLab.PluginInfrastructure/3.3/Interfaces/IApplication.cs
r7259 r9363 37 37 /// Main entry point for the application. 38 38 /// </summary> 39 void Run( );39 void Run(ICommandLineArgument[] args); 40 40 } 41 41 } -
branches/OaaS/HeuristicLab.PluginInfrastructure/3.3/LightweightApplicationManager.cs
r7662 r9363 75 75 foreach (Type t in GetTypes(type)) { 76 76 object instance = null; 77 try { instance = Activator.CreateInstance(t); } catch { } 77 try { instance = Activator.CreateInstance(t); } 78 catch { } 78 79 if (instance != null) instances.Add(instance); 79 80 } … … 127 128 var assemblyTypes = assembly.GetTypes(); 128 129 129 var buildTypes = from t in assembly.GetTypes() 130 where CheckTypeCompatibility(type, t) 131 where !IsNonDiscoverableType(t) 132 where onlyInstantiable == false || 133 (!t.IsAbstract && !t.IsInterface && !t.HasElementType) 134 select BuildType(t, type); 130 var matchingTypes = from assemblyType in assembly.GetTypes() 131 let t = assemblyType.BuildType(type) 132 where t != null 133 where t.IsSubTypeOf(type) 134 where !t.IsNonDiscoverableType() 135 where onlyInstantiable == false || (!t.IsAbstract && !t.IsInterface && !t.HasElementType) 136 where includeGenericTypeDefinitions || !t.IsGenericTypeDefinition 137 select t; 135 138 136 return from t in buildTypes 137 where includeGenericTypeDefinitions || !t.IsGenericTypeDefinition 138 select t; 139 } catch (TypeLoadException) { 140 return Enumerable.Empty<Type>(); 141 } catch (ReflectionTypeLoadException) { 139 return matchingTypes; 140 } 141 catch (TypeLoadException) { 142 142 return Enumerable.Empty<Type>(); 143 143 } 144 } 145 146 private static bool IsNonDiscoverableType(Type t) { 147 return t.GetCustomAttributes(typeof(NonDiscoverableTypeAttribute), false).Any(); 148 } 149 150 private static bool CheckTypeCompatibility(Type type, Type other) { 151 if (type.IsAssignableFrom(other)) 152 return true; 153 if (type.IsGenericType && other.IsGenericType) { 154 var otherGenericArguments = other.GetGenericArguments(); 155 var typeGenericArguments = type.GetGenericArguments(); 156 157 //check type arguments count 158 if (otherGenericArguments.Length != typeGenericArguments.Length) 159 return false; 160 161 //check type arguments & constraints 162 int i = 0; 163 foreach (var genericArgument in typeGenericArguments) { 164 if (otherGenericArguments[i].IsGenericParameter) { 165 foreach (var constraint in otherGenericArguments[i].GetGenericParameterConstraints()) 166 if (!constraint.IsAssignableFrom(genericArgument)) return false; 167 } else if (genericArgument != otherGenericArguments[i]) return false; 168 i++; 169 } 170 //check types 171 try { 172 var otherGenericTypeDefinition = other.GetGenericTypeDefinition(); 173 if (type.IsAssignableFrom(otherGenericTypeDefinition.MakeGenericType(typeGenericArguments))) 174 return true; 175 } catch (Exception) { } 144 catch (ReflectionTypeLoadException) { 145 return Enumerable.Empty<Type>(); 176 146 } 177 return false;178 }179 private static Type BuildType(Type type, Type protoType) {180 if (type.IsGenericType && protoType.IsGenericType)181 return type.GetGenericTypeDefinition().MakeGenericType(protoType.GetGenericArguments());182 else183 return type;184 147 } 185 148 -
branches/OaaS/HeuristicLab.PluginInfrastructure/3.3/Main.cs
r7259 r9363 34 34 /// <param name="args">Command line arguments</param> 35 35 public static void Run(string[] args) { 36 if (!FrameworkVersionErrorDialog.NET4FullProfileInstalled) { 36 if ((!FrameworkVersionErrorDialog.NET4FullProfileInstalled && !FrameworkVersionErrorDialog.MonoInstalled) 37 || (FrameworkVersionErrorDialog.MonoInstalled && !FrameworkVersionErrorDialog.MonoCorrectVersionInstalled)) { 37 38 Application.EnableVisualStyles(); 38 39 Application.SetCompatibleTextRenderingDefault(false); … … 42 43 Application.EnableVisualStyles(); 43 44 Application.SetCompatibleTextRenderingDefault(false); 44 Application.Run(new StarterForm( ));45 Application.Run(new StarterForm(args)); 45 46 } 46 47 catch (Exception ex) { -
branches/OaaS/HeuristicLab.PluginInfrastructure/3.3/Manager/PluginManager.cs
r7259 r9363 110 110 /// </summary> 111 111 /// <param name="appInfo">application to run</param> 112 public void Run(ApplicationDescription appInfo ) {112 public void Run(ApplicationDescription appInfo, ICommandLineArgument[] args) { 113 113 if (!initialized) throw new InvalidOperationException("PluginManager is not initialized. DiscoverAndCheckPlugins() must be called before Run()"); 114 114 // create a separate AppDomain for the application … … 129 129 applicationManager.PrepareApplicationDomain(applications, plugins); 130 130 OnApplicationStarted(new PluginInfrastructureEventArgs(appInfo)); 131 applicationManager.Run(appInfo );131 applicationManager.Run(appInfo, args); 132 132 } 133 133 finally { -
branches/OaaS/HeuristicLab.PluginInfrastructure/3.3/Properties/AssemblyInfo.cs.frame
r7259 r9363 56 56 // 57 57 [assembly: AssemblyVersion("3.3.0.0")] 58 [assembly: AssemblyFileVersion("3.3. 6.$WCREV$")]58 [assembly: AssemblyFileVersion("3.3.7.$WCREV$")] -
branches/OaaS/HeuristicLab.PluginInfrastructure/3.3/Resources.resx
r6413 r9363 123 123 </data> 124 124 <data name="ArrowUp" type="System.Resources.ResXFileRef, System.Windows.Forms"> 125 <value>Resources\ vs2008imagelibrary_commonelements_objects_arrow_up.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>125 <value>Resources\VS2008ImageLibrary_CommonElements_Objects_Arrow_Up.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value> 126 126 </data> 127 127 <data name="Assembly" type="System.Resources.ResXFileRef, System.Windows.Forms"> 128 <value>Resources\ vs2008imagelibrary_objects_assembly.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>128 <value>Resources\VS2008ImageLibrary_Objects_Assembly.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value> 129 129 </data> 130 130 <data name="Document" type="System.Resources.ResXFileRef, System.Windows.Forms"> … … 150 150 </data> 151 151 <data name="Install" type="System.Resources.ResXFileRef, System.Windows.Forms"> 152 <value>Resources\ vs2008imagelibrary_objects_install.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>152 <value>Resources\VS2008ImageLibrary_Objects_Install.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value> 153 153 </data> 154 154 <data name="Internet" type="System.Resources.ResXFileRef, System.Windows.Forms"> … … 195 195 </data> 196 196 <data name="UpdateAvailable" type="System.Resources.ResXFileRef, System.Windows.Forms"> 197 <value> resources\updateavailable.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>197 <value>Resources\UpdateAvailable.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value> 198 198 </data> 199 199 </root> -
branches/OaaS/HeuristicLab.PluginInfrastructure/3.3/SandboxApplicationManager.cs
r7586 r9363 115 115 /// </summary> 116 116 /// <param name="appInfo">Description of the application to run</param> 117 internal void Run(ApplicationDescription appInfo ) {117 internal void Run(ApplicationDescription appInfo, ICommandLineArgument[] args) { 118 118 IApplication runnablePlugin = (IApplication)Activator.CreateInstance(appInfo.DeclaringAssemblyName, appInfo.DeclaringTypeName).Unwrap(); 119 119 try { 120 runnablePlugin.Run( );120 runnablePlugin.Run(args); 121 121 } 122 122 finally { … … 261 261 /// <returns>Enumerable of the discovered types.</returns> 262 262 private static IEnumerable<Type> GetTypes(Type type, Assembly assembly, bool onlyInstantiable, bool includeGenericTypeDefinitions) { 263 var buildTypes = from t in assembly.GetTypes() 264 where CheckTypeCompatibility(type, t) 265 where !IsNonDiscoverableType(t) 266 where onlyInstantiable == false || 267 (!t.IsAbstract && !t.IsInterface && !t.HasElementType) 268 select BuildType(t, type); 269 270 return from t in buildTypes 271 where includeGenericTypeDefinitions || !t.IsGenericTypeDefinition 272 select t; 273 } 274 275 276 private static bool IsNonDiscoverableType(Type t) { 277 return t.GetCustomAttributes(typeof(NonDiscoverableTypeAttribute), false).Any(); 278 } 279 280 private static bool CheckTypeCompatibility(Type type, Type other) { 281 if (type.IsAssignableFrom(other)) 282 return true; 283 if (type.IsGenericType && other.IsGenericType) { 284 var otherGenericArguments = other.GetGenericArguments(); 285 var typeGenericArguments = type.GetGenericArguments(); 286 287 //check type arguments count 288 if (otherGenericArguments.Length != typeGenericArguments.Length) 289 return false; 290 291 //check type arguments & constraints 292 int i = 0; 293 foreach (var genericArgument in typeGenericArguments) { 294 if (otherGenericArguments[i].IsGenericParameter) { 295 foreach (var constraint in otherGenericArguments[i].GetGenericParameterConstraints()) 296 if (!constraint.IsAssignableFrom(genericArgument)) return false; 297 } else if (genericArgument != otherGenericArguments[i]) return false; 298 i++; 299 } 300 //check types 301 try { 302 var otherGenericTypeDefinition = other.GetGenericTypeDefinition(); 303 if (type.IsAssignableFrom(otherGenericTypeDefinition.MakeGenericType(typeGenericArguments))) 304 return true; 305 } 306 catch (Exception) { } 307 } 308 return false; 309 } 310 private static Type BuildType(Type type, Type protoType) { 311 if (type.IsGenericType && protoType.IsGenericType) 312 return type.GetGenericTypeDefinition().MakeGenericType(protoType.GetGenericArguments()); 313 else 314 return type; 263 var matchingTypes = from assemblyType in assembly.GetTypes() 264 let t = assemblyType.BuildType(type) 265 where t != null 266 where t.IsSubTypeOf(type) 267 where !t.IsNonDiscoverableType() 268 where onlyInstantiable == false || (!t.IsAbstract && !t.IsInterface && !t.HasElementType) 269 where includeGenericTypeDefinitions || !t.IsGenericTypeDefinition 270 select t; 271 272 return matchingTypes; 315 273 } 316 274 -
branches/OaaS/HeuristicLab.PluginInfrastructure/3.3/Starter/StarterForm.Designer.cs
r7967 r9363 181 181 this.Name = "StarterForm"; 182 182 this.Text = "HeuristicLab Starter"; 183 this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.MainForm_FormClosing); 183 this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.StarterForm_FormClosing); 184 this.Load += new System.EventHandler(this.StarterForm_Load); 184 185 this.ResumeLayout(false); 185 186 -
branches/OaaS/HeuristicLab.PluginInfrastructure/3.3/Starter/StarterForm.cs
r7259 r9363 26 26 using System.Linq; 27 27 using System.Threading; 28 using System.Threading.Tasks; 28 29 using System.Windows.Forms; 29 30 using HeuristicLab.PluginInfrastructure.Advanced; 30 31 using HeuristicLab.PluginInfrastructure.Manager; 31 using System.Threading.Tasks;32 32 33 33 namespace HeuristicLab.PluginInfrastructure.Starter { … … 39 39 private const string pluginManagerItemName = "Plugin Manager"; 40 40 private const string updatePluginsItemName = "Updates Available"; 41 41 private const string optimizerItemName = "Optimizer"; 42 43 private readonly ICommandLineArgument[] arguments; 42 44 43 45 private ListViewItem pluginManagerListViewItem; … … 46 48 private SplashScreen splashScreen; 47 49 private bool updatesAvailable = false; 50 48 51 /// <summary> 49 52 /// Initializes an instance of the starter form. … … 63 66 pluginManager = new PluginManager(pluginPath); 64 67 splashScreen = new SplashScreen(pluginManager, 1000); 68 splashScreen.VisibleChanged += new EventHandler(splashScreen_VisibleChanged); 65 69 splashScreen.Show(this, "Loading HeuristicLab..."); 66 70 … … 69 73 70 74 CheckUpdatesAvailableAsync(); 75 } 76 77 /// <summary> 78 /// Creates a new StarterForm and passes the arguments in <paramref name="args"/>. 79 /// </summary> 80 /// <param name="args">The arguments that should be processed</param> 81 public StarterForm(string[] args) 82 : this() { 83 arguments = CommandLineArgumentHandling.GetArguments(args); 84 } 85 86 protected override void SetVisibleCore(bool value) { 87 value &= !(arguments.OfType<HideStarterArgument>().Any() || arguments.OfType<OpenArgument>().Any()); 88 if (!value) HandleArguments(); 89 base.SetVisibleCore(value); 90 } 91 92 #region Events 93 private void StarterForm_Load(object sender, EventArgs e) { 94 HandleArguments(); 95 } 96 97 private void StarterForm_FormClosing(object sender, FormClosingEventArgs e) { 98 splashScreen.Close(); 99 abortRequested = true; 100 } 101 102 private void applicationsListView_SelectedIndexChanged(object sender, EventArgs e) { 103 startButton.Enabled = applicationsListView.SelectedItems.Count > 0; 104 } 105 106 private void applicationsListView_ItemActivate(object sender, EventArgs e) { 107 if (applicationsListView.SelectedItems.Count > 0) { 108 ListViewItem selected = applicationsListView.SelectedItems[0]; 109 if (selected.Text == pluginManagerItemName) { 110 if (pluginManager.Plugins.Any(x => x.PluginState == PluginState.Loaded)) { 111 MessageBox.Show("Installation Manager cannot be started while another HeuristicLab application is active." + Environment.NewLine + 112 "Please stop all active HeuristicLab applications and try again.", "Plugin Manager", 113 MessageBoxButtons.OK, MessageBoxIcon.Information); 114 } else { 115 try { 116 Cursor = Cursors.AppStarting; 117 using (InstallationManagerForm form = new InstallationManagerForm(pluginManager)) { 118 form.ShowDialog(this); 119 } 120 UpdateApplicationsList(); 121 } 122 finally { 123 Cursor = Cursors.Arrow; 124 } 125 } 126 } else if (selected.Text == updatePluginsItemName) { 127 if (pluginManager.Plugins.Any(x => x.PluginState == PluginState.Loaded)) { 128 MessageBox.Show("Updating is not possible while another HeuristicLab application is active." + Environment.NewLine + 129 "Please stop all active HeuristicLab applications and try again.", "Update plugins", 130 MessageBoxButtons.OK, MessageBoxIcon.Information); 131 } else { 132 try { 133 Cursor = Cursors.AppStarting; 134 using (PluginUpdaterForm form = new PluginUpdaterForm(pluginManager)) { 135 form.ShowDialog(this); 136 } 137 updatesAvailable = false; 138 CheckUpdatesAvailableAsync(); 139 UpdateApplicationsList(); 140 } 141 finally { 142 Cursor = Cursors.Arrow; 143 } 144 } 145 } else { 146 ApplicationDescription app = (ApplicationDescription)applicationsListView.SelectedItems[0].Tag; 147 StartApplication(app, arguments); 148 } 149 } 150 } 151 152 private void largeIconsButton_Click(object sender, EventArgs e) { 153 applicationsListView.View = View.LargeIcon; 154 } 155 156 private void detailsButton_Click(object sender, EventArgs e) { 157 applicationsListView.View = View.Details; 158 foreach (ColumnHeader column in applicationsListView.Columns) { 159 if (applicationsListView.Items.Count > 0) 160 column.AutoResize(ColumnHeaderAutoResizeStyle.ColumnContent); 161 else column.AutoResize(ColumnHeaderAutoResizeStyle.HeaderSize); 162 } 163 } 164 165 private void aboutButton_Click(object sender, EventArgs e) { 166 List<IPluginDescription> plugins = new List<IPluginDescription>(pluginManager.Plugins.OfType<IPluginDescription>()); 167 using (var dialog = new AboutDialog(plugins)) { 168 dialog.ShowDialog(); 169 } 170 } 171 172 private void splashScreen_VisibleChanged(object sender, EventArgs e) { 173 // close hidden starter form 174 if (!splashScreen.Visible && arguments != null && 175 (arguments.OfType<HideStarterArgument>().Any() || arguments.OfType<OpenArgument>().Any())) 176 Close(); 177 } 178 #endregion 179 180 #region Helpers 181 private void UpdateApplicationsList() { 182 if (InvokeRequired) Invoke((Action)UpdateApplicationsList); 183 else { 184 applicationsListView.Items.Clear(); 185 AddPluginManagerItem(); 186 AddUpdatePluginsItem(); 187 188 foreach (ApplicationDescription info in pluginManager.Applications) { 189 ListViewItem item = new ListViewItem(info.Name, 0); 190 item.Tag = info; 191 item.Group = applicationsListView.Groups["Applications"]; 192 item.SubItems.Add(new ListViewItem.ListViewSubItem(item, info.Version.ToString())); 193 item.SubItems.Add(new ListViewItem.ListViewSubItem(item, info.Description)); 194 item.ToolTipText = info.Description; 195 applicationsListView.Items.Add(item); 196 } 197 foreach (ColumnHeader column in applicationsListView.Columns) { 198 if (applicationsListView.Items.Count > 0) 199 column.AutoResize(ColumnHeaderAutoResizeStyle.ColumnContent); 200 else column.AutoResize(ColumnHeaderAutoResizeStyle.HeaderSize); 201 } 202 } 203 } 204 205 private void AddPluginManagerItem() { 206 FileVersionInfo pluginInfrastructureVersion = FileVersionInfo.GetVersionInfo(GetType().Assembly.Location); 207 pluginManagerListViewItem = new ListViewItem(pluginManagerItemName, 0); 208 pluginManagerListViewItem.Group = applicationsListView.Groups["Plugin Management"]; 209 pluginManagerListViewItem.SubItems.Add(new ListViewItem.ListViewSubItem(pluginManagerListViewItem, pluginInfrastructureVersion.FileVersion)); 210 pluginManagerListViewItem.SubItems.Add(new ListViewItem.ListViewSubItem(pluginManagerListViewItem, "Install, upgrade or delete plugins")); 211 pluginManagerListViewItem.ToolTipText = "Install, upgrade or delete plugins"; 212 213 applicationsListView.Items.Add(pluginManagerListViewItem); 214 } 215 216 private void AddUpdatePluginsItem() { 217 if (updatesAvailable) { 218 var updateListViewItem = new ListViewItem(updatePluginsItemName, 1); 219 updateListViewItem.Group = applicationsListView.Groups["Plugin Management"]; 220 updateListViewItem.SubItems.Add(new ListViewItem.ListViewSubItem(updateListViewItem, "")); 221 updateListViewItem.SubItems.Add(new ListViewItem.ListViewSubItem(updateListViewItem, "Download and install updates")); 222 updateListViewItem.ToolTipText = "Download and install updates"; 223 224 applicationsListView.Items.Add(updateListViewItem); 225 } 71 226 } 72 227 … … 108 263 } 109 264 110 /// <summary> 111 /// Creates a new StarterForm and tries to start application with <paramref name="appName"/> immediately. 112 /// </summary> 113 /// <param name="appName">Name of the application</param> 114 public StarterForm(string appName) 115 : this() { 265 private void HandleArguments() { 266 try { 267 if (arguments.OfType<OpenArgument>().Any() && !arguments.OfType<StartArgument>().Any()) { 268 InitiateApplicationStart(optimizerItemName); 269 } 270 foreach (var argument in arguments) { 271 if (argument is StartArgument) { 272 var arg = (StartArgument)argument; 273 InitiateApplicationStart(arg.Value); 274 } 275 } 276 } 277 catch (AggregateException ex) { 278 ErrorHandling.ShowErrorDialog(this, "One or more errors occurred while initializing the application.", ex); 279 } 280 } 281 282 private void InitiateApplicationStart(string appName) { 116 283 var appDesc = (from desc in pluginManager.Applications 117 where desc.Name == appName284 where desc.Name.Equals(appName) 118 285 select desc).SingleOrDefault(); 119 286 if (appDesc != null) { 120 StartApplication(appDesc );287 StartApplication(appDesc, arguments); 121 288 } else { 122 289 MessageBox.Show("Cannot start application " + appName + ".", … … 127 294 } 128 295 129 private void applicationsListView_ItemActivate(object sender, EventArgs e) { 130 if (applicationsListView.SelectedItems.Count > 0) { 131 ListViewItem selected = applicationsListView.SelectedItems[0]; 132 if (selected.Text == pluginManagerItemName) { 133 if (pluginManager.Plugins.Any(x => x.PluginState == PluginState.Loaded)) { 134 MessageBox.Show("Installation Manager cannot be started while another HeuristicLab application is active." + Environment.NewLine + 135 "Please stop all active HeuristicLab applications and try again.", "Plugin Manager", 136 MessageBoxButtons.OK, MessageBoxIcon.Information); 137 } else { 138 try { 139 Cursor = Cursors.AppStarting; 140 using (InstallationManagerForm form = new InstallationManagerForm(pluginManager)) { 141 form.ShowDialog(this); 142 } 143 UpdateApplicationsList(); 144 } 145 finally { 146 Cursor = Cursors.Arrow; 147 } 148 } 149 } else if (selected.Text == updatePluginsItemName) { 150 if (pluginManager.Plugins.Any(x => x.PluginState == PluginState.Loaded)) { 151 MessageBox.Show("Updating is not possible while another HeuristicLab application is active." + Environment.NewLine + 152 "Please stop all active HeuristicLab applications and try again.", "Update plugins", 153 MessageBoxButtons.OK, MessageBoxIcon.Information); 154 } else { 155 try { 156 Cursor = Cursors.AppStarting; 157 using (PluginUpdaterForm form = new PluginUpdaterForm(pluginManager)) { 158 form.ShowDialog(this); 159 } 160 updatesAvailable = false; 161 CheckUpdatesAvailableAsync(); 162 UpdateApplicationsList(); 163 } 164 finally { 165 Cursor = Cursors.Arrow; 166 } 167 } 168 } else { 169 ApplicationDescription app = (ApplicationDescription)applicationsListView.SelectedItems[0].Tag; 170 StartApplication(app); 171 } 172 } 173 } 174 175 private void UpdateApplicationsList() { 176 if (InvokeRequired) Invoke((Action)UpdateApplicationsList); 177 else { 178 applicationsListView.Items.Clear(); 179 AddPluginManagerItem(); 180 AddUpdatePluginsItem(); 181 182 foreach (ApplicationDescription info in pluginManager.Applications) { 183 ListViewItem item = new ListViewItem(info.Name, 0); 184 item.Tag = info; 185 item.Group = applicationsListView.Groups["Applications"]; 186 item.SubItems.Add(new ListViewItem.ListViewSubItem(item, info.Version.ToString())); 187 item.SubItems.Add(new ListViewItem.ListViewSubItem(item, info.Description)); 188 item.ToolTipText = info.Description; 189 applicationsListView.Items.Add(item); 190 } 191 foreach (ColumnHeader column in applicationsListView.Columns) { 192 if (applicationsListView.Items.Count > 0) 193 column.AutoResize(ColumnHeaderAutoResizeStyle.ColumnContent); 194 else column.AutoResize(ColumnHeaderAutoResizeStyle.HeaderSize); 195 } 196 } 197 } 198 199 private void AddPluginManagerItem() { 200 FileVersionInfo pluginInfrastructureVersion = FileVersionInfo.GetVersionInfo(GetType().Assembly.Location); 201 pluginManagerListViewItem = new ListViewItem(pluginManagerItemName, 0); 202 pluginManagerListViewItem.Group = applicationsListView.Groups["Plugin Management"]; 203 pluginManagerListViewItem.SubItems.Add(new ListViewItem.ListViewSubItem(pluginManagerListViewItem, pluginInfrastructureVersion.FileVersion)); 204 pluginManagerListViewItem.SubItems.Add(new ListViewItem.ListViewSubItem(pluginManagerListViewItem, "Install, upgrade or delete plugins")); 205 pluginManagerListViewItem.ToolTipText = "Install, upgrade or delete plugins"; 206 207 applicationsListView.Items.Add(pluginManagerListViewItem); 208 } 209 210 private void AddUpdatePluginsItem() { 211 if (updatesAvailable) { 212 var updateListViewItem = new ListViewItem(updatePluginsItemName, 1); 213 updateListViewItem.Group = applicationsListView.Groups["Plugin Management"]; 214 updateListViewItem.SubItems.Add(new ListViewItem.ListViewSubItem(updateListViewItem, "")); 215 updateListViewItem.SubItems.Add(new ListViewItem.ListViewSubItem(updateListViewItem, "Download and install updates")); 216 updateListViewItem.ToolTipText = "Download and install updates"; 217 218 applicationsListView.Items.Add(updateListViewItem); 219 } 220 } 221 222 private void StartApplication(ApplicationDescription app) { 296 private void StartApplication(ApplicationDescription app, ICommandLineArgument[] args) { 223 297 splashScreen.Show("Loading " + app.Name); 224 298 Thread t = new Thread(delegate() { … … 227 301 try { 228 302 if (!abortRequested) { 229 pluginManager.Run(app );303 pluginManager.Run(app, args); 230 304 } 231 305 stopped = true; … … 241 315 t.Start(); 242 316 } 243 244 private void applicationsListView_SelectedIndexChanged(object sender, EventArgs e) { 245 startButton.Enabled = applicationsListView.SelectedItems.Count > 0; 246 } 247 248 private void largeIconsButton_Click(object sender, EventArgs e) { 249 applicationsListView.View = View.LargeIcon; 250 } 251 252 private void detailsButton_Click(object sender, EventArgs e) { 253 applicationsListView.View = View.Details; 254 foreach (ColumnHeader column in applicationsListView.Columns) { 255 if (applicationsListView.Items.Count > 0) 256 column.AutoResize(ColumnHeaderAutoResizeStyle.ColumnContent); 257 else column.AutoResize(ColumnHeaderAutoResizeStyle.HeaderSize); 258 } 259 } 260 261 private void MainForm_FormClosing(object sender, FormClosingEventArgs e) { 262 splashScreen.Close(); 263 abortRequested = true; 264 } 265 266 private void aboutButton_Click(object sender, EventArgs e) { 267 List<IPluginDescription> plugins = new List<IPluginDescription>(pluginManager.Plugins.OfType<IPluginDescription>()); 268 using (var dialog = new AboutDialog(plugins)) { 269 dialog.ShowDialog(); 270 } 271 } 317 #endregion 272 318 } 273 319 } -
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.