- Timestamp:
- 11/18/09 18:33:30 (15 years ago)
- Location:
- branches/PluginInfrastructure Refactoring/HeuristicLab.PluginInfrastructure
- Files:
-
- 1 added
- 1 deleted
- 23 edited
- 13 moved
Legend:
- Unmodified
- Added
- Removed
-
branches/PluginInfrastructure Refactoring/HeuristicLab.PluginInfrastructure/Attributes/ApplicationAttribute.cs
r2488 r2504 27 27 /// <summary> 28 28 /// This attribute can be used to specify meta data for applications. 29 /// For example to specify name , versionand description of applications.29 /// For example to specify name and description of applications. 30 30 /// </summary> 31 31 [AttributeUsage(AttributeTargets.Class)] 32 public class ApplicationAttribute : System.Attribute {32 public sealed class ApplicationAttribute : System.Attribute { 33 33 private string name; 34 34 /// <summary> 35 /// Gets or setsthe name of the application.35 /// Gets the name of the application. 36 36 /// </summary> 37 37 public string Name { 38 38 get { return name; } 39 set { name = value; }40 39 } 41 42 //private string version;43 ///// <summary>44 ///// Gets or sets the version of the application.45 ///// </summary>46 //public string Version {47 // get { return version; }48 // set { version = value; }49 //}50 40 51 41 private string description; 52 42 /// <summary> 53 /// Gets or setsthe description of the application.43 /// Gets the description of the application. 54 44 /// </summary> 55 45 public string Description { 56 46 get { return description; } 57 set { description = value; }58 47 } 59 48 60 49 private bool restartOnErrors; 61 50 /// <summary> 62 /// Gets or sets the boolean flagwhether the plugin should be automatically restarted when it is closed because of an exception (for services).51 /// Gets whether the plugin should be automatically restarted when it is closed because of an exception (for services). 63 52 /// </summary> 64 53 public bool RestartOnErrors { 65 54 get { return restartOnErrors; } 66 set { restartOnErrors = value; }67 55 } 68 56 … … 72 60 /// </summary> 73 61 public ApplicationAttribute(string name) 74 : this(name, "") {62 : this(name, String.Empty) { 75 63 } 76 64 … … 84 72 } 85 73 86 ///// <summary>87 ///// Initializes a new instance of <see cref="ApplicationAttribute"/>.88 ///// <param name="name">Name of the application</param>89 ///// <param name="description">Description of the application</param>90 ///// <param name="version">Version string of the application</param>91 ///// </summary>92 //public ApplicationAttribute(string name, string description, string version)93 // : this(name, description, version, false) {94 //}95 96 74 /// <summary> 97 75 /// Initializes a new instance of <see cref="ApplicationAttribute"/>. … … 102 80 /// </summary> 103 81 public ApplicationAttribute(string name, string description, bool restartOnErrors) { 82 if (name == null) throw new ArgumentNullException("name", "Application name is null."); 83 if (description == null) throw new ArgumentNullException("description", "Application description is null."); 104 84 this.name = name; 105 85 this.description = description; -
branches/PluginInfrastructure Refactoring/HeuristicLab.PluginInfrastructure/Attributes/AssemblyBuildDateAttribute.cs
r2475 r2504 30 30 /// </summary> 31 31 [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = false)] 32 public class AssemblyBuildDateAttribute : Attribute {32 public sealed class AssemblyBuildDateAttribute : Attribute { 33 33 private DateTime buildDate; 34 34 /// <summary> 35 /// Gets or setsthe build date.35 /// Gets the build date. 36 36 /// </summary> 37 37 public DateTime BuildDate { 38 38 get { return buildDate; } 39 set { buildDate = value; }40 39 } 40 41 41 /// <summary> 42 42 /// Initializes a new instance of <see cref="AssemblyBuildDateAttribute"/> with the given … … 44 44 /// </summary> 45 45 /// <exception cref="FormatException">Thrown when the time stamp could not be parsed as build date.</exception> 46 /// <param name=" timeStamp">The build date of the assembly.</param>47 public AssemblyBuildDateAttribute(string timeStamp)46 /// <param name="buildDate">The build date of the assembly.</param> 47 public AssemblyBuildDateAttribute(string buildDate) 48 48 : base() { 49 50 if(!DateTime.TryParse(timeStamp, out buildDate)) { 51 throw new FormatException("Can't parse AssemblyBuildDate " + timeStamp); 49 if (!DateTime.TryParse(buildDate, out this.buildDate)) { 50 throw new FormatException("Can't parse AssemblyBuildDate " + buildDate); 52 51 } 53 52 } -
branches/PluginInfrastructure Refactoring/HeuristicLab.PluginInfrastructure/Attributes/PluginAttribute.cs
r2488 r2504 27 27 /// <summary> 28 28 /// This attribute can be used to specify meta data for plugins. 29 /// For example to specify name , versionand description of plugins.29 /// For example to specify name and description of plugins. 30 30 /// </summary> 31 31 [AttributeUsage(AttributeTargets.Class)] 32 public class PluginAttribute : System.Attribute {32 public sealed class PluginAttribute : System.Attribute { 33 33 private string name; 34 34 /// <summary> 35 /// Gets or setsthe name of the plugin.35 /// Gets the name of the plugin. 36 36 /// </summary> 37 37 public string Name { 38 38 get { return name; } 39 // set { name = value; }40 39 } 41 42 //private string version;43 ///// <summary>44 ///// Gets or sets the version of the plugin.45 ///// </summary>46 //public string Version {47 // get { return version; }48 // set { version = value; }49 //}50 40 51 41 private string description; 52 42 /// <summary> 53 /// Gets or setsthe description of the plugin.43 /// Gets the description of the plugin. 54 44 /// </summary> 55 45 public string Description { 56 46 get { return description; } 57 // set { description = value; }58 47 } 59 48 … … 75 64 this.description = description; 76 65 } 77 78 ///// <summary>79 ///// Initializes a new instance of <see cref="PluginDescriptionAttribute"/>.80 ///// <param name="name">Name of the plugin</param>81 ///// <param name="description">Description of the plugin</param>82 ///// <param name="version">Version string of the plugin</param>83 ///// </summary>84 //public PluginDescriptionAttribute(string name, string description, string version) {85 // this.name = name;86 // this.version = version;87 // this.description = description;88 //}89 66 } 90 67 } -
branches/PluginInfrastructure Refactoring/HeuristicLab.PluginInfrastructure/Attributes/PluginDependencyAttribute.cs
r2481 r2504 33 33 34 34 /// <summary> 35 /// Gets or setsthe name of the plugin that is needed to load a plugin.35 /// Gets the name of the plugin that is needed to load a plugin. 36 36 /// </summary> 37 37 public string Dependency { 38 38 get { return dependency; } 39 // set { dependency = value; }40 39 } 41 40 … … 45 44 /// </summary> 46 45 public PluginDependencyAttribute(string dependency) { 46 if (string.IsNullOrEmpty(dependency)) throw new ArgumentException("Dependency is null or empty.", "dependency"); 47 47 this.dependency = dependency; 48 48 } -
branches/PluginInfrastructure Refactoring/HeuristicLab.PluginInfrastructure/Attributes/PluginFileAttribute.cs
r2496 r2504 23 23 using System.Collections.Generic; 24 24 using System.Text; 25 using System.IO; 25 26 26 27 namespace HeuristicLab.PluginInfrastructure { … … 40 41 /// </summary> 41 42 [AttributeUsage(AttributeTargets.Class, AllowMultiple = true)] 42 public class PluginFileAttribute : System.Attribute {43 private string file name;43 public sealed class PluginFileAttribute : System.Attribute { 44 private string fileName; 44 45 45 46 /// <summary> 46 /// Gets or sets the filename of the plugin.47 /// Gets the file name of the plugin. 47 48 /// </summary> 48 public string Filename { 49 get { return filename; } 50 //set { filename = value; } 49 public string FileName { 50 get { return fileName; } 51 51 } 52 52 53 private PluginFileType file type = PluginFileType.Data;53 private PluginFileType fileType = PluginFileType.Data; 54 54 55 55 /// <summary> 56 /// Gets or sets the filetype of the plugin file.56 /// Gets the file type of the plugin file. 57 57 /// </summary> 58 public PluginFileType Filetype { 59 get { return filetype; } 60 //set { filetype = value; } 58 public PluginFileType FileType { 59 get { return fileType; } 61 60 } 62 61 63 62 /// <summary> 64 63 /// Initializes a new instance of <see cref="PluginFileAttribute"/>. 65 /// <param name="file name">Name of the file</param>66 /// <param name=" type">Type of the file (Assembly, Executable, Data, License)</param>64 /// <param name="fileName">Name of the file</param> 65 /// <param name="fileType">Type of the file (Assembly, NativeDll, Data, License)</param> 67 66 /// </summary> 68 public PluginFileAttribute(string filename, PluginFileType type) { 69 this.filename = filename; 70 this.filetype = type; 67 public PluginFileAttribute(string fileName, PluginFileType fileType) { 68 if (string.IsNullOrEmpty(fileName)) throw new ArgumentException("File name is empty.", "fileName"); 69 // NB: doesn't check if the file actually exists 70 this.fileName = fileName; 71 this.fileType = fileType; 71 72 } 72 73 } -
branches/PluginInfrastructure Refactoring/HeuristicLab.PluginInfrastructure/BaseClasses/ApplicationBase.cs
r2488 r2504 27 27 namespace HeuristicLab.PluginInfrastructure { 28 28 /// <summary> 29 /// Defaultimplementation for the IApplication interface.29 /// Abstract base implementation for the IApplication interface. 30 30 /// </summary> 31 31 public abstract class ApplicationBase : IApplication { … … 33 33 /// Initializes a new instance of <see cref="ApplicationBase"/>. 34 34 /// </summary> 35 p ublicApplicationBase() { }35 protected ApplicationBase() { } 36 36 37 37 private ApplicationAttribute ApplicationAttribute { … … 40 40 41 41 // exactly one attribute of the type ClassInfoAttribute must be given 42 if (appAttributes.Length != 1) { 42 if (appAttributes.Length == 0) { 43 throw new InvalidPluginException("ApplicationAttribute on type " + this.GetType() + " is missing."); 44 } else if (appAttributes.Length > 1) { 43 45 throw new InvalidPluginException("Found multiple ApplicationAttributes on type " + this.GetType()); 44 46 } … … 58 60 59 61 /// <summary> 60 /// Gets the version of the application.61 /// </summary>62 public Version Version {63 get {64 return this.GetType().Assembly.GetName().Version;65 }66 }67 68 /// <summary>69 62 /// Gets the description of the application. 70 63 /// </summary> 71 64 public string Description { 72 65 get { 73 var appDescAttribute = ApplicationAttribute; 74 // if the description is not explicitly set in the attribute then the name of the application is used as default 75 if (string.IsNullOrEmpty(appDescAttribute.Description)) { 76 return appDescAttribute.Name; 77 } else { 78 return appDescAttribute.Description; 79 } 80 } 81 } 82 83 /// <summary> 84 /// Gets the boolean flag whether the application should by restarted after exceptions. 85 /// </summary> 86 public bool RestartOnErrors { 87 get { 88 return ApplicationAttribute.RestartOnErrors; 66 return ApplicationAttribute.Description; 89 67 } 90 68 } -
branches/PluginInfrastructure Refactoring/HeuristicLab.PluginInfrastructure/BaseClasses/PluginBase.cs
r2503 r2504 29 29 namespace HeuristicLab.PluginInfrastructure { 30 30 /// <summary> 31 /// Defaultimplementation of the IPlugin interface.31 /// Abstract base implementation of the IPlugin interface. 32 32 /// </summary> 33 33 public abstract class PluginBase : IPlugin { … … 35 35 /// Initializes a new instance of <see cref="PluginBase"/>. 36 36 /// </summary> 37 p ublicPluginBase() { }37 protected PluginBase() { } 38 38 39 39 private PluginAttribute PluginAttribute { … … 41 41 object[] pluginAttributes = this.GetType().GetCustomAttributes(typeof(PluginAttribute), false); 42 42 // exactly one attribute of the type PluginDescriptionAttribute must be given 43 if (pluginAttributes.Length != 1) { 43 if (pluginAttributes.Length == 0) { 44 throw new InvalidPluginException("PluginAttribute on type " + this.GetType() + " is missing."); 45 } else if (pluginAttributes.Length > 1) { 44 46 throw new InvalidPluginException("Found multiple PluginAttributes on type " + this.GetType()); 45 47 } … … 56 58 } 57 59 58 59 /// <inheritdoc/>60 public IEnumerable<string> FileNames {61 get {62 // get all attributes of type PluginFileAttribute, multiple usage is possible63 return from x in this.GetType().GetCustomAttributes(typeof(PluginFileAttribute), false)64 let pluginFileAttr = (PluginFileAttribute)x65 select pluginFileAttr.Filename;66 }67 }68 69 60 /// <inhertitdoc> 70 61 public virtual void OnLoad() { } -
branches/PluginInfrastructure Refactoring/HeuristicLab.PluginInfrastructure/ControlManager.cs
r2488 r2504 30 30 namespace HeuristicLab.PluginInfrastructure { 31 31 32 public class ControlManager {32 public static class ControlManager { 33 33 // singleton: only one control manager allowed in each application (i.e. AppDomain) 34 34 private static IControlManager controlManager; -
branches/PluginInfrastructure Refactoring/HeuristicLab.PluginInfrastructure/HeuristicLab.PluginInfrastructure.csproj
r2503 r2504 86 86 </ItemGroup> 87 87 <ItemGroup> 88 <Compile Include="ApplicationDescription.cs" />89 88 <Compile Include="Attributes\ApplicationAttribute.cs" /> 90 89 <Compile Include="Attributes\AssemblyBuildDateAttribute.cs" /> … … 94 93 <Compile Include="BaseClasses\ApplicationBase.cs" /> 95 94 <Compile Include="BaseClasses\PluginBase.cs" /> 96 <Compile Include="DefaultApplicationManager.cs" />97 95 <Compile Include="Interfaces\IApplicationManager.cs" /> 98 96 <Compile Include="Interfaces\IApplicationDescription.cs" /> 99 97 <Compile Include="Interfaces\IApplication.cs" /> 100 <Compile Include="Interfaces\IControl.cs" />101 98 <Compile Include="Interfaces\IControlManager.cs" /> 102 99 <Compile Include="Interfaces\IPlugin.cs" /> … … 104 101 <Compile Include="Interfaces\IPluginDescription.cs" /> 105 102 <Compile Include="InvalidPluginException.cs" /> 106 <Compile Include="PluginDescription.cs" /> 103 <Compile Include="Manager\ApplicationDescription.cs" /> 104 <Compile Include="Manager\DefaultApplicationManager.cs" /> 105 <Compile Include="Manager\PluginDescription.cs" /> 106 <Compile Include="Manager\PluginInfrastructureEventArgs.cs" /> 107 <Compile Include="Manager\PluginManager.cs" /> 108 <Compile Include="Manager\PluginValidator.cs" /> 107 109 <Compile Include="PluginDescriptionIterator.cs" /> 108 110 <Compile Include="ApplicationManager.cs" /> 109 <Compile Include="PluginInfrastructureEventArgs.cs" />110 <Compile Include="PluginManager.cs" />111 111 <Compile Include="PluginState.cs" /> 112 <Compile Include="PluginValidator.cs" />113 112 <Compile Include="Properties\AssemblyInfo.cs" /> 114 113 <EmbeddedResource Include="Properties\Resources.resx"> … … 116 115 <LastGenOutput>Resources.Designer.cs</LastGenOutput> 117 116 <SubType>Designer</SubType> 117 </EmbeddedResource> 118 <EmbeddedResource Include="Starter\MainForm.resx"> 119 <DependentUpon>MainForm.cs</DependentUpon> 120 </EmbeddedResource> 121 <EmbeddedResource Include="Starter\SplashScreen.resx"> 122 <DependentUpon>SplashScreen.cs</DependentUpon> 118 123 </EmbeddedResource> 119 124 <Compile Include="Properties\Resources.Designer.cs"> … … 134 139 <DesignTimeSharedInput>True</DesignTimeSharedInput> 135 140 </Compile> 141 <Compile Include="Starter\MainForm.cs"> 142 <SubType>Form</SubType> 143 </Compile> 144 <Compile Include="Starter\MainForm.Designer.cs"> 145 <DependentUpon>MainForm.cs</DependentUpon> 146 </Compile> 147 <Compile Include="Starter\SplashScreen.cs"> 148 <SubType>Form</SubType> 149 </Compile> 150 <Compile Include="Starter\SplashScreen.Designer.cs"> 151 <DependentUpon>SplashScreen.cs</DependentUpon> 152 </Compile> 136 153 </ItemGroup> 137 154 <ItemGroup> 138 <Folder Include="Manager\" /> 155 <Content Include="Resources\Details.gif" /> 156 <Content Include="Resources\HeuristicLab.ico" /> 157 <Content Include="Resources\LargeIcons.gif" /> 158 <Content Include="Resources\List.gif" /> 159 <Content Include="Resources\Logo_white.gif" /> 139 160 </ItemGroup> 140 161 <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> -
branches/PluginInfrastructure Refactoring/HeuristicLab.PluginInfrastructure/Interfaces/IApplication.cs
r2481 r2504 27 27 public interface IApplication { 28 28 string Name { get; } 29 Version Version { get; }30 29 string Description { get; } 31 bool RestartOnErrors { get; }32 30 void Run(); 33 31 } -
branches/PluginInfrastructure Refactoring/HeuristicLab.PluginInfrastructure/Interfaces/IApplicationDescription.cs
r2488 r2504 24 24 25 25 namespace HeuristicLab.PluginInfrastructure { 26 /// <summary> 27 /// Represents meta-data of an application. 28 /// </summary> 26 29 public interface IApplicationDescription { 30 /// <summary> 31 /// Gets the name of the application. 32 /// </summary> 27 33 string Name { get; } 28 Version Version { get; } 29 string DeclaringAssemblyName { get; } 30 string DeclaringTypeName { get; } 34 /// <summary> 35 /// Gets the description of the application. 36 /// </summary> 37 string Description { get; } 31 38 } 32 39 } -
branches/PluginInfrastructure Refactoring/HeuristicLab.PluginInfrastructure/Interfaces/IApplicationManager.cs
r2489 r2504 31 31 /// </summary> 32 32 public interface IApplicationManager { 33 /// <summary> 34 /// Gets all discovered plugins. 35 /// </summary> 33 36 IEnumerable<IPluginDescription> Plugins { get; } 37 /// <summary> 38 /// Gets all discovered applications. 39 /// </summary> 34 40 IEnumerable<IApplicationDescription> Applications { get; } 35 41 42 /// <summary> 43 /// Dynamically loads assemblies given in binary form. 44 /// </summary> 45 /// <param name="assemblies">Assemblies that should be loaded in binary form.</param> 36 46 void LoadAssemblies(IEnumerable<byte[]> assemblies); 37 47 48 /// <summary> 49 /// Discovers and creates instances of <typeparamref name="T"/> and all types implementing or inheriting <typeparamref name="T"/> (directly and indirectly) declared in any assembly of <paramref name="plugin"/>. 50 /// </summary> 51 /// <typeparam name="T">The type or super-type to discover.</typeparam> 52 /// <param name="plugin">The declaring plugin.</param> 53 /// <returns>An enumerable of instances of the discovered types.</returns> 38 54 IEnumerable<T> GetInstances<T>(IPluginDescription plugin) where T : class; 55 /// <summary> 56 /// Discovers and creates instances of <typeparamref name="T"/> and all types implementing or inheriting <typeparamref name="T"/> (directly and indirectly). 57 /// </summary> 58 /// <typeparam name="T">The type or super-type to discover.</typeparam> 59 /// <returns>An enumerable of instances of the discovered types.</returns> 39 60 IEnumerable<T> GetInstances<T>() where T : class; 40 61 62 /// <summary> 63 /// Discovers all types implementing or inheriting <paramref name="type"/> (directly and indirectly). 64 /// </summary> 65 /// <param name="type">The type to discover.</param> 66 /// <returns>An enumerable of discovered types.</returns> 41 67 IEnumerable<Type> GetTypes(Type type); 42 IEnumerable<Type> GetTypes(Type type, IPluginDescription pluginDescription); 68 /// <summary> 69 /// Discovers all types implementing or inheriting <paramref name="type"/> (directly and indirectly) that are declaed in any assembly of <paramref name="plugin"/>. 70 /// </summary> 71 /// <param name="type">The type to discover.</param> 72 /// <param name="plugin">The declaring plugin.</param> 73 /// <returns>An enumerable of discovered types.</returns> 74 IEnumerable<Type> GetTypes(Type type, IPluginDescription plugin); 43 75 } 44 76 } -
branches/PluginInfrastructure Refactoring/HeuristicLab.PluginInfrastructure/Interfaces/IControlManager.cs
r1189 r2504 34 34 /// </summary> 35 35 /// <param name="control">The control to display.</param> 36 void ShowControl( IControlcontrol);36 void ShowControl(object control); 37 37 } 38 38 } -
branches/PluginInfrastructure Refactoring/HeuristicLab.PluginInfrastructure/Interfaces/IPlugin.cs
r2503 r2504 28 28 /// Represents a plugin. 29 29 /// Plugin developers have to include exactly one class that implements this interface in one of the 30 /// assemblies of the plugin. Plugin developers can use the properties of this interface to store 31 /// plugin data (name, version, files, update location ...). 32 /// The method OnLoad() is called by the framework when the plugin is loaded (application start). 30 /// assemblies of the plugin. 31 /// OnLoad() and OnUnLoad() are called by the framework when the plugin is loaded/unloaded. 33 32 /// </summary> 34 33 public interface IPlugin { … … 37 36 /// </summary> 38 37 string Name { get; } 39 ///// <summary>40 ///// Gets the version of the plugin.41 ///// </summary>42 //Version Version { get; }43 /// <summary>44 /// Gets all file names that are bundled with this plugin including all assembly files (*.dll)45 /// </summary>46 IEnumerable<string> FileNames { get; }47 38 48 39 /// <summary> -
branches/PluginInfrastructure Refactoring/HeuristicLab.PluginInfrastructure/Interfaces/IPluginDescription.cs
r2488 r2504 24 24 25 25 namespace HeuristicLab.PluginInfrastructure { 26 /// <summary> 27 /// Represents meta-data of a plugin. 28 /// </summary> 26 29 public interface IPluginDescription { 30 /// <summary> 31 /// Gets the name of the plugin. 32 /// </summary> 27 33 string Name { get; } 28 Version Version { get; }29 DateTime BuildDate { get; }30 PluginState PluginState { get; }31 IEnumerable<string> Files { get; }32 IEnumerable<IPluginDescription> Dependencies { get; }33 IEnumerable<string> Assemblies { get; }34 void Enable();35 void Disable();36 void Load();37 void Unload();38 34 } 39 35 } -
branches/PluginInfrastructure Refactoring/HeuristicLab.PluginInfrastructure/InvalidPluginException.cs
r2481 r2504 23 23 using System.Collections.Generic; 24 24 using System.Text; 25 using System.Runtime.Serialization; 25 26 26 27 namespace HeuristicLab.PluginInfrastructure { … … 28 29 /// Exception class for invalid plugins. 29 30 /// </summary> 30 public class InvalidPluginException : Exception { 31 [Serializable] 32 public sealed class InvalidPluginException : Exception { 33 public InvalidPluginException() : base() { } 31 34 public InvalidPluginException(string message) : base(message) { } 35 public InvalidPluginException(string message, Exception exception) : base(message, exception) { } 36 private InvalidPluginException(SerializationInfo info, StreamingContext contex) : base(info, contex) { } 32 37 } 33 38 } -
branches/PluginInfrastructure Refactoring/HeuristicLab.PluginInfrastructure/Manager/ApplicationDescription.cs
r2503 r2504 29 29 /// </summary> 30 30 [Serializable] 31 publicclass ApplicationDescription : IApplicationDescription {31 internal sealed class ApplicationDescription : IApplicationDescription { 32 32 private string name; 33 33 … … 44 44 /// Gets or sets the version of the application. 45 45 /// </summary> 46 publicVersion Version {46 internal Version Version { 47 47 get { return version; } 48 48 set { version = value; } … … 62 62 /// Gets or sets the boolean flag if the application should be automatically restarted. 63 63 /// </summary> 64 publicbool AutoRestart {64 internal bool AutoRestart { 65 65 get { return autoRestart; } 66 66 set { autoRestart = value; } … … 71 71 /// Gets or sets the name of the assembly that contains the IApplication type. 72 72 /// </summary> 73 publicstring DeclaringAssemblyName {73 internal string DeclaringAssemblyName { 74 74 get { return declaringAssemblyName; } 75 75 set { declaringAssemblyName = value; } … … 80 80 /// Gets or sets the name of the type that implements the interface IApplication. 81 81 /// </summary> 82 publicstring DeclaringTypeName {82 internal string DeclaringTypeName { 83 83 get { return declaringTypeName; } 84 84 set { declaringTypeName = value; } -
branches/PluginInfrastructure Refactoring/HeuristicLab.PluginInfrastructure/Manager/DefaultApplicationManager.cs
r2503 r2504 32 32 namespace HeuristicLab.PluginInfrastructure.Manager { 33 33 34 publicsealed class DefaultApplicationManager : MarshalByRefObject, IApplicationManager {34 internal sealed class DefaultApplicationManager : MarshalByRefObject, IApplicationManager { 35 35 internal event EventHandler<PluginInfrastructureEventArgs> PluginLoaded; 36 36 internal event EventHandler<PluginInfrastructureEventArgs> PluginUnloaded; … … 42 42 private List<IPlugin> loadedPlugins; 43 43 44 private List< IPluginDescription> plugins;44 private List<PluginDescription> plugins; 45 45 /// <summary> 46 46 /// Gets all plugins. 47 47 /// </summary> 48 48 public IEnumerable<IPluginDescription> Plugins { 49 get { return plugins; } 50 internal set { plugins = new List<IPluginDescription>(value); } 51 } 52 53 private List<IApplicationDescription> applications; 49 get { return plugins.Cast<IPluginDescription>(); } 50 } 51 52 private List<ApplicationDescription> applications; 54 53 /// <summary> 55 54 /// Gets all installed applications. 56 55 /// </summary> 57 56 public IEnumerable<IApplicationDescription> Applications { 58 get { return applications ; }57 get { return applications.Cast<IApplicationDescription>(); } 59 58 } 60 59 … … 72 71 } 73 72 74 internal void PrepareApplicationDomain(IEnumerable< IApplicationDescription> apps, IEnumerable<IPluginDescription> plugins) {75 this.plugins = new List< IPluginDescription>(plugins);76 this.applications = new List< IApplicationDescription>(apps);73 internal void PrepareApplicationDomain(IEnumerable<ApplicationDescription> apps, IEnumerable<PluginDescription> plugins) { 74 this.plugins = new List<PluginDescription>(plugins); 75 this.applications = new List<ApplicationDescription>(apps); 77 76 PluginInfrastructure.ApplicationManager.RegisterApplicationManager(this); 78 77 LoadPlugins(plugins); 79 78 } 80 79 81 private void LoadPlugins(IEnumerable< IPluginDescription> plugins) {80 private void LoadPlugins(IEnumerable<PluginDescription> plugins) { 82 81 // load all loadable plugins (all dependencies available) into the execution context 83 82 foreach (var desc in PluginDescriptionIterator.IterateInDependencyOrder(plugins.Where(x => x.PluginState != PluginState.Disabled))) { … … 96 95 } 97 96 98 internal void Run( IApplicationDescription appInfo) {97 internal void Run(ApplicationDescription appInfo) { 99 98 IApplication runnablePlugin = (IApplication)Activator.CreateInstance(appInfo.DeclaringAssemblyName, appInfo.DeclaringTypeName).Unwrap(); 100 99 try { 101 100 runnablePlugin.Run(); 102 }103 catch (Exception e) {104 throw new Exception(String.Format(105 "Unexpected exception caught: \"{0}\"\r\n" +106 "Type: {1}\r\n" +107 "Plugin {2}:\r\n{3}",108 e.Message,109 e.GetType().FullName,110 appInfo.Name,111 e.ToString()));112 101 } 113 102 finally { … … 156 145 /// <param name="asm">Declaring assembly.</param> 157 146 /// <returns>Enumerable of the created instances.</returns> 158 p ublic IEnumerable<T> GetInstances<T>(Assembly asm) where T : class {147 private static IEnumerable<T> GetInstances<T>(Assembly asm) where T : class { 159 148 return from t in GetTypes(typeof(T), asm) 160 149 where !t.IsAbstract && !t.IsInterface && !t.HasElementType … … 201 190 /// <returns>Enumerable of the discovered types.</returns> 202 191 public IEnumerable<Type> GetTypes(Type type, IPluginDescription pluginDescription) { 192 PluginDescription pluginDesc = (PluginDescription)pluginDescription; 203 193 return from asm in AppDomain.CurrentDomain.GetAssemblies() 204 where pluginDesc ription.Assemblies.Any(asmPath => Path.GetFullPath(asmPath) == Path.GetFullPath(asm.Location))194 where pluginDesc.Assemblies.Any(asmPath => Path.GetFullPath(asmPath) == Path.GetFullPath(asm.Location)) 205 195 from t in GetTypes(type, asm) 206 196 select t; … … 213 203 /// <param name="assembly">Assembly that should be searched for types.</param> 214 204 /// <returns>Enumerable of the discovered types.</returns> 215 private IEnumerable<Type> GetTypes(Type type, Assembly assembly) {205 private static IEnumerable<Type> GetTypes(Type type, Assembly assembly) { 216 206 return from t in assembly.GetTypes() 217 207 where type.IsAssignableFrom(t) -
branches/PluginInfrastructure Refactoring/HeuristicLab.PluginInfrastructure/Manager/PluginDescription.cs
r2503 r2504 30 30 /// </summary> 31 31 [Serializable] 32 public class PluginDescription : IPluginDescription { 32 internal sealed class PluginDescription : IPluginDescription { 33 private int nTimesLoaded; 34 33 35 private string name; 34 36 /// <summary> … … 37 39 public string Name { 38 40 get { return name; } 39 set { name = value; }41 internal set { name = value; } 40 42 } 41 43 private Version version; … … 43 45 /// Gets or sets the version of the plugin. 44 46 /// </summary> 45 publicVersion Version {47 internal Version Version { 46 48 get { return version; } 47 49 set { version = value; } … … 51 53 /// Gets or sets the build date of the plugin. 52 54 /// </summary> 53 publicDateTime BuildDate {55 internal DateTime BuildDate { 54 56 get { return buildDate; } 55 57 set { buildDate = value; } … … 64 66 } 65 67 66 private int nTimesLoaded;67 public void Disable() {68 if (pluginState != PluginState.Undefined)69 throw new InvalidOperationException("Can't disabled a plugin in state " + pluginState);70 pluginState = PluginState.Disabled;71 }72 73 public void Enable() {74 if (pluginState != PluginState.Undefined)75 throw new InvalidOperationException("Can't enabled a plugin in state " + pluginState);76 pluginState = PluginState.Enabled;77 }78 79 public void Load() {80 if (!(pluginState == PluginState.Enabled || pluginState == PluginState.Loaded))81 throw new InvalidOperationException("Can't loaded a plugin in state " + pluginState);82 pluginState = PluginState.Loaded;83 nTimesLoaded++;84 }85 86 public void Unload() {87 if (pluginState != PluginState.Loaded)88 throw new InvalidOperationException("Can't unload a plugin in state " + pluginState);89 nTimesLoaded--;90 if (nTimesLoaded == 0) pluginState = PluginState.Enabled;91 }92 68 93 69 private List<string> files = new List<string>(); … … 96 72 /// These files are deleted when the plugin is removed or updated. 97 73 /// </summary> 98 publicIEnumerable<string> Files {74 internal IEnumerable<string> Files { 99 75 get { return files; } 100 76 } … … 104 80 } 105 81 106 private List< IPluginDescription> dependencies = new List<IPluginDescription>();82 private List<PluginDescription> dependencies = new List<PluginDescription>(); 107 83 /// <summary> 108 84 /// Gets all dependencies of the plugin. 109 85 /// </summary> 110 public IEnumerable<IPluginDescription> Dependencies {86 internal IEnumerable<PluginDescription> Dependencies { 111 87 get { return dependencies; } 112 88 } 113 89 114 publicvoid AddDependency(PluginDescription dependency) {90 internal void AddDependency(PluginDescription dependency) { 115 91 dependencies.Add(dependency); 116 92 } … … 121 97 /// Gets the names of the assemblies that belong to this plugin. 122 98 /// </summary> 123 publicIEnumerable<string> Assemblies {99 internal IEnumerable<string> Assemblies { 124 100 get { return assemblies; } 125 101 // set { assemblies = value; } … … 130 106 } 131 107 132 public PluginDescription() { 133 nTimesLoaded = 0; 108 internal PluginDescription() { 134 109 pluginState = PluginState.Undefined; 135 110 } 111 112 internal void Disable() { 113 if (pluginState != PluginState.Undefined) 114 throw new InvalidOperationException("Can't disabled a plugin in state " + pluginState); 115 pluginState = PluginState.Disabled; 116 } 117 118 internal void Enable() { 119 if (pluginState != PluginState.Undefined) 120 throw new InvalidOperationException("Can't enabled a plugin in state " + pluginState); 121 pluginState = PluginState.Enabled; 122 } 123 124 internal void Load() { 125 if (!(pluginState == PluginState.Enabled || pluginState == PluginState.Loaded)) 126 throw new InvalidOperationException("Can't loaded a plugin in state " + pluginState); 127 pluginState = PluginState.Loaded; 128 nTimesLoaded++; 129 } 130 131 internal void Unload() { 132 if (pluginState != PluginState.Loaded) 133 throw new InvalidOperationException("Can't unload a plugin in state " + pluginState); 134 nTimesLoaded--; 135 if (nTimesLoaded == 0) pluginState = PluginState.Enabled; 136 } 137 136 138 137 139 /// <summary> … … 151 153 /// <returns><c>true</c> if it is equal, <c>false</c> otherwise.</returns> 152 154 public override bool Equals(object obj) { 153 if (!(obj is PluginDescription)) 154 return false; 155 PluginDescription other = (PluginDescription)obj; 155 PluginDescription other = obj as PluginDescription; 156 if (other == null) return false; 156 157 157 158 return other.Name == this.Name && other.Version == this.Version; -
branches/PluginInfrastructure Refactoring/HeuristicLab.PluginInfrastructure/Manager/PluginInfrastructureEventArgs.cs
r2503 r2504 27 27 // to be replaced by GenericEventArgs 28 28 [Serializable] 29 publicclass PluginInfrastructureEventArgs : EventArgs {30 publicstring Action { get; private set; }31 publicobject Entity { get; private set; }32 publicPluginInfrastructureEventArgs(string action, object entity) {29 internal sealed class PluginInfrastructureEventArgs : EventArgs { 30 internal string Action { get; private set; } 31 internal object Entity { get; private set; } 32 internal PluginInfrastructureEventArgs(string action, object entity) { 33 33 this.Action = action; 34 34 this.Entity = entity; -
branches/PluginInfrastructure Refactoring/HeuristicLab.PluginInfrastructure/Manager/PluginManager.cs
r2503 r2504 35 35 /// Class to manage different plugins. 36 36 /// </summary> 37 publicsealed class PluginManager : MarshalByRefObject {37 internal sealed class PluginManager : MarshalByRefObject { 38 38 /// <summary> 39 39 /// Event handler for actions in the plugin manager. 40 40 /// </summary> 41 publicevent EventHandler<PluginInfrastructureEventArgs> Action;41 internal event EventHandler<PluginInfrastructureEventArgs> Action; 42 42 43 43 private string pluginDir; … … 49 49 /// Gets all installed applications. 50 50 /// </summary> 51 publicIEnumerable<ApplicationDescription> Applications {51 internal IEnumerable<ApplicationDescription> Applications { 52 52 get { return applications; } 53 53 } … … 56 56 private bool initialized; 57 57 58 publicPluginManager(string pluginDir) {58 internal PluginManager(string pluginDir) { 59 59 this.pluginDir = pluginDir; 60 60 plugins = new List<PluginDescription>(); … … 63 63 } 64 64 65 publicvoid Reset() {65 internal void Reset() { 66 66 initialized = false; 67 67 if (plugins != null && plugins.Any(x => x.PluginState == PluginState.Loaded)) throw new InvalidOperationException("Reset() is not allowed while applications are active."); … … 73 73 /// Determines installed plugins and checks if all plugins are loadable. 74 74 /// </summary> 75 publicvoid DiscoverAndCheckPlugins() {75 internal void DiscoverAndCheckPlugins() { 76 76 OnAction(new PluginInfrastructureEventArgs("Initializing", "PluginInfrastructure")); 77 77 AppDomainSetup setup = AppDomain.CurrentDomain.SetupInformation; … … 80 80 try { 81 81 pluginDomain = AppDomain.CreateDomain("plugin domain", null, setup); 82 PluginValidator remoteValidator = (PluginValidator)pluginDomain.CreateInstanceAndUnwrap("HeuristicLab.PluginInfraStructure.Manager", "HeuristicLab.PluginInfrastructure.Manager.Loader"); 82 Type pluginValidatorType = typeof(PluginValidator); 83 PluginValidator remoteValidator = (PluginValidator)pluginDomain.CreateInstanceAndUnwrap(pluginValidatorType.Assembly.FullName, pluginValidatorType.FullName, true, BindingFlags.NonPublic | BindingFlags.Instance, null, null, null, null, null); 83 84 remoteValidator.PluginDir = pluginDir; 84 85 // forward all events from the remoteValidator to listeners … … 109 110 /// </summary> 110 111 /// <param name="appInfo">application to run</param> 111 publicvoid Run(ApplicationDescription appInfo) {112 internal void Run(ApplicationDescription appInfo) { 112 113 if (!initialized) throw new InvalidOperationException("PluginManager is not initialized. DiscoverAndCheckPlugins() must be called before Run()"); 113 114 // create a separate AppDomain for the application … … 121 122 setup.PrivateBinPath = pluginDir; 122 123 applicationDomain = AppDomain.CreateDomain(appInfo.Name, null, setup); 124 Type applicationManagerType = typeof(DefaultApplicationManager); 123 125 DefaultApplicationManager applicationManager = 124 (DefaultApplicationManager)applicationDomain.CreateInstanceAndUnwrap( "HeuristicLab.PluginInfraStructure.Manager", "HeuristicLab.PluginInfrastructure.Manager.DefaultApplicationManager");126 (DefaultApplicationManager)applicationDomain.CreateInstanceAndUnwrap(applicationManagerType.Assembly.FullName, applicationManagerType.FullName, true, BindingFlags.NonPublic | BindingFlags.Instance, null, null, null, null, null); 125 127 applicationManager.PluginLoaded += applicationManager_PluginLoaded; 126 128 applicationManager.PluginUnloaded += applicationManager_PluginUnloaded; 127 applicationManager.PrepareApplicationDomain( 128 new List<IApplicationDescription>(applications.Cast<IApplicationDescription>()), 129 new List<IPluginDescription>(plugins.Cast<IPluginDescription>())); 129 applicationManager.PrepareApplicationDomain(applications, plugins); 130 130 OnAction(new PluginInfrastructureEventArgs("Started application", appInfo)); 131 131 applicationManager.Run(appInfo); -
branches/PluginInfrastructure Refactoring/HeuristicLab.PluginInfrastructure/Manager/PluginValidator.cs
r2503 r2504 57 57 } 58 58 59 publicstring PluginDir { get; set; }60 61 publicPluginValidator() {59 internal string PluginDir { get; set; } 60 61 internal PluginValidator() { 62 62 this.pluginDependencies = new Dictionary<PluginDescription, List<string>>(); 63 63 … … 114 114 115 115 foreach (IApplication application in GetApplications()) { 116 Type appType = application.GetType(); 117 ApplicationAttribute attr = (from x in appType.GetCustomAttributes(typeof(ApplicationAttribute), false) 118 select (ApplicationAttribute)x).Single(); 116 119 ApplicationDescription info = new ApplicationDescription(); 117 120 info.Name = application.Name; 118 info.Version = app lication.Version;121 info.Version = appType.Assembly.GetName().Version; 119 122 info.Description = application.Description; 120 info.AutoRestart = a pplication.RestartOnErrors;121 info.DeclaringAssemblyName = app lication.GetType().Assembly.GetName().Name;122 info.DeclaringTypeName = app lication.GetType().Namespace + "." + application.GetType().Name;123 info.AutoRestart = attr.RestartOnErrors; 124 info.DeclaringAssemblyName = appType.Assembly.GetName().Name; 125 info.DeclaringTypeName = appType.Namespace + "." + application.GetType().Name; 123 126 124 127 applications.Add(info); … … 126 129 } 127 130 128 private IEnumerable<IApplication> GetApplications() {131 private static IEnumerable<IApplication> GetApplications() { 129 132 return from asm in AppDomain.CurrentDomain.GetAssemblies() 130 133 from t in asm.GetTypes() … … 206 209 } 207 210 211 var buildDates = from attr in CustomAttributeData.GetCustomAttributes(pluginType.Assembly) 212 where IsAttributeDataForType(attr, typeof(AssemblyBuildDateAttribute)) 213 select (string)attr.ConstructorArguments[0].Value; 214 208 215 // minimal sanity check of the attribute values 209 216 if (!string.IsNullOrEmpty(pluginName) && 210 217 pluginFiles.Count > 0 && 211 pluginAssemblies.Count > 0) { 218 pluginAssemblies.Count > 0 && 219 buildDates.Count() == 1) { 212 220 // create a temporary PluginDescription that contains the attribute values 213 221 PluginDescription info = new PluginDescription(); 214 222 info.Name = pluginName; 215 223 info.Version = pluginType.Assembly.GetName().Version; 224 info.BuildDate = DateTime.Parse(buildDates.Single(), System.Globalization.CultureInfo.InvariantCulture); 216 225 info.AddAssemblies(pluginAssemblies); 217 226 info.AddFiles(pluginFiles); … … 224 233 } 225 234 226 private bool IsAttributeDataForType(CustomAttributeData attributeData, Type attributeType) {235 private static bool IsAttributeDataForType(CustomAttributeData attributeData, Type attributeType) { 227 236 return attributeData.Constructor.DeclaringType.AssemblyQualifiedName == attributeType.AssemblyQualifiedName; 228 237 } … … 266 275 // load all loadable plugins (all dependencies available) into the execution context 267 276 foreach (var desc in PluginDescriptionIterator.IterateInDependencyOrder(pluginDescriptions 268 .Cast<IPluginDescription>()269 277 .Where(x => x.PluginState != PluginState.Disabled))) { 270 278 List<Type> types = new List<Type>(); … … 290 298 291 299 // checks if all declared plugin files are actually available and disables plugins with missing files 292 private void CheckPluginFiles(IEnumerable<PluginDescription> pluginDescriptions) {300 private static void CheckPluginFiles(IEnumerable<PluginDescription> pluginDescriptions) { 293 301 foreach (PluginDescription desc in pluginDescriptions) { 294 302 if (!CheckPluginFiles(desc)) { … … 298 306 } 299 307 300 private bool CheckPluginFiles(PluginDescription PluginDescription) {301 foreach (string filename in PluginDescription.Files) {308 private static bool CheckPluginFiles(PluginDescription pluginDescription) { 309 foreach (string filename in pluginDescription.Files) { 302 310 if (!File.Exists(filename)) { 303 311 return false; -
branches/PluginInfrastructure Refactoring/HeuristicLab.PluginInfrastructure/PluginDescriptionIterator.cs
r2488 r2504 24 24 using System.Text; 25 25 26 namespace HeuristicLab.PluginInfrastructure {27 publicstatic class PluginDescriptionIterator {28 public static IEnumerable<IPluginDescription> IterateInDependencyOrder(IEnumerable<IPluginDescription> pluginDescriptions) {26 namespace HeuristicLab.PluginInfrastructure.Manager { 27 internal static class PluginDescriptionIterator { 28 internal static IEnumerable<PluginDescription> IterateInDependencyOrder(IEnumerable<PluginDescription> pluginDescriptions) { 29 29 // list to make sure we yield each description only once 30 List< IPluginDescription> yieldedDescriptions = new List<IPluginDescription>();30 List<PluginDescription> yieldedDescriptions = new List<PluginDescription>(); 31 31 foreach (var desc in pluginDescriptions) { 32 32 foreach (var dependency in IterateInDependencyOrder(desc.Dependencies)) { -
branches/PluginInfrastructure Refactoring/HeuristicLab.PluginInfrastructure/Properties/AssemblyInfo.frame
r886 r2504 25 25 using HeuristicLab.PluginInfrastructure; 26 26 using System.Security; 27 using System; 27 28 28 29 // General Information about an assembly is controlled through the following … … 37 38 [assembly: AssemblyTrademark("")] 38 39 [assembly: AssemblyCulture("")] 39 [assembly: AllowPartiallyTrustedCallers] 40 [assembly: System.Resources.NeutralResourcesLanguage("en")] 41 [assembly: CLSCompliant(true)] 40 42 41 43 // Setting ComVisible to false makes the types in this assembly not visible -
branches/PluginInfrastructure Refactoring/HeuristicLab.PluginInfrastructure/Properties/Resources.Designer.cs
r2 r2504 1 #region License Information 2 /* HeuristicLab 3 * Copyright (C) 2002-2008 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 //------------------------------------------------------------------------------ 1 //------------------------------------------------------------------------------ 23 2 // <auto-generated> 24 3 // This code was generated by a tool. 25 // Runtime Version:2.0.50727. 14334 // Runtime Version:2.0.50727.4200 26 5 // 27 6 // Changes to this file may cause incorrect behavior and will be lost if … … 81 60 } 82 61 } 62 63 internal static System.Drawing.Bitmap Details { 64 get { 65 object obj = ResourceManager.GetObject("Details", resourceCulture); 66 return ((System.Drawing.Bitmap)(obj)); 67 } 68 } 69 70 internal static System.Drawing.Icon HeuristicLab { 71 get { 72 object obj = ResourceManager.GetObject("HeuristicLab", resourceCulture); 73 return ((System.Drawing.Icon)(obj)); 74 } 75 } 76 77 internal static System.Drawing.Bitmap LargeIcons { 78 get { 79 object obj = ResourceManager.GetObject("LargeIcons", resourceCulture); 80 return ((System.Drawing.Bitmap)(obj)); 81 } 82 } 83 84 internal static System.Drawing.Bitmap List { 85 get { 86 object obj = ResourceManager.GetObject("List", resourceCulture); 87 return ((System.Drawing.Bitmap)(obj)); 88 } 89 } 90 91 internal static System.Drawing.Bitmap Logo_white { 92 get { 93 object obj = ResourceManager.GetObject("Logo_white", resourceCulture); 94 return ((System.Drawing.Bitmap)(obj)); 95 } 96 } 83 97 } 84 98 } -
branches/PluginInfrastructure Refactoring/HeuristicLab.PluginInfrastructure/Properties/Resources.resx
r2 r2504 118 118 <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> 119 119 </resheader> 120 <assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /> 121 <data name="Details" type="System.Resources.ResXFileRef, System.Windows.Forms"> 122 <value>..\Resources\Details.gif;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value> 123 </data> 124 <data name="HeuristicLab" type="System.Resources.ResXFileRef, System.Windows.Forms"> 125 <value>..\Resources\HeuristicLab.ico;System.Drawing.Icon, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value> 126 </data> 127 <data name="LargeIcons" type="System.Resources.ResXFileRef, System.Windows.Forms"> 128 <value>..\Resources\LargeIcons.gif;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value> 129 </data> 130 <data name="List" type="System.Resources.ResXFileRef, System.Windows.Forms"> 131 <value>..\Resources\List.gif;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value> 132 </data> 133 <data name="Logo_white" type="System.Resources.ResXFileRef, System.Windows.Forms"> 134 <value>..\Resources\Logo_white.gif;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value> 135 </data> 120 136 </root> -
branches/PluginInfrastructure Refactoring/HeuristicLab.PluginInfrastructure/Properties/Settings.Designer.cs
r854 r2504 2 2 // <auto-generated> 3 3 // This code was generated by a tool. 4 // Runtime Version:2.0.50727. 30534 // Runtime Version:2.0.50727.4200 5 5 // 6 6 // Changes to this file may cause incorrect behavior and will be lost if … … 32 32 } 33 33 } 34 35 [global::System.Configuration.ApplicationScopedSettingAttribute()] 36 [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 37 [global::System.Configuration.DefaultSettingValueAttribute("")] 38 public string User { 39 get { 40 return ((string)(this["User"])); 41 } 42 } 43 44 [global::System.Configuration.ApplicationScopedSettingAttribute()] 45 [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 46 [global::System.Configuration.DefaultSettingValueAttribute("")] 47 public string Organization { 48 get { 49 return ((string)(this["Organization"])); 50 } 51 } 34 52 } 35 53 } -
branches/PluginInfrastructure Refactoring/HeuristicLab.PluginInfrastructure/Properties/Settings.settings
r854 r2504 6 6 <Value Profile="(Default)">plugins</Value> 7 7 </Setting> 8 <Setting Name="User" Type="System.String" Scope="Application"> 9 <Value Profile="(Default)" /> 10 </Setting> 11 <Setting Name="Organization" Type="System.String" Scope="Application"> 12 <Value Profile="(Default)" /> 13 </Setting> 8 14 </Settings> 9 15 </SettingsFile> -
branches/PluginInfrastructure Refactoring/HeuristicLab.PluginInfrastructure/Starter/MainForm.Designer.cs
r2485 r2504 20 20 #endregion 21 21 22 namespace HeuristicLab {22 namespace HeuristicLab.PluginInfrastructure { 23 23 partial class MainForm { 24 24 /// <summary> … … 32 32 /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> 33 33 protected override void Dispose(bool disposing) { 34 if (disposing && (components != null)) {34 if (disposing && (components != null)) { 35 35 components.Dispose(); 36 36 } … … 131 131 this.detailsButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); 132 132 this.detailsButton.AutoSize = true; 133 this.detailsButton.Image = global::HeuristicLab.Properties.Resources.Details;133 this.detailsButton.Image = HeuristicLab.PluginInfrastructure.Properties.Resources.Details; 134 134 this.detailsButton.Location = new System.Drawing.Point(68, 511); 135 135 this.detailsButton.Name = "detailsButton"; … … 144 144 this.listButton.AutoSize = true; 145 145 this.listButton.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; 146 this.listButton.Image = global::HeuristicLab.Properties.Resources.List;146 this.listButton.Image = HeuristicLab.PluginInfrastructure.Properties.Resources.List; 147 147 this.listButton.Location = new System.Drawing.Point(40, 511); 148 148 this.listButton.Name = "listButton"; … … 157 157 this.largeIconsButton.AutoSize = true; 158 158 this.largeIconsButton.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; 159 this.largeIconsButton.Image = global::HeuristicLab.Properties.Resources.LargeIcons;159 this.largeIconsButton.Image = HeuristicLab.PluginInfrastructure.Properties.Resources.LargeIcons; 160 160 this.largeIconsButton.Location = new System.Drawing.Point(12, 511); 161 161 this.largeIconsButton.Name = "largeIconsButton"; -
branches/PluginInfrastructure Refactoring/HeuristicLab.PluginInfrastructure/Starter/MainForm.cs
r2497 r2504 33 33 using System.IO; 34 34 35 namespace HeuristicLab {35 namespace HeuristicLab.PluginInfrastructure { 36 36 public partial class MainForm : Form { 37 37 … … 44 44 InitializeComponent(); 45 45 46 abortRequested = false;47 46 string pluginPath = Path.GetFullPath(HeuristicLab.PluginInfrastructure.Properties.Settings.Default.PluginDir); 48 47 pluginManager = new PluginManager(pluginPath); … … 142 141 } 143 142 144 public void ShowErrorMessageBox(Exception ex) { 145 MessageBox.Show(BuildErrorMessage(ex), 146 "Error - " + ex.GetType().Name, 147 MessageBoxButtons.OK, 148 MessageBoxIcon.Error); 143 private void ShowErrorMessageBox(Exception ex) { 144 MessageBoxOptions options = RightToLeft == RightToLeft.Yes ? MessageBoxOptions.RightAlign | MessageBoxOptions.RtlReading : MessageBoxOptions.DefaultDesktopOnly; 145 MessageBox.Show(this, 146 BuildErrorMessage(ex), 147 "Error - " + ex.GetType().Name, 148 MessageBoxButtons.OK, 149 MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, options); 149 150 } 150 private st ring BuildErrorMessage(Exception ex) {151 private static string BuildErrorMessage(Exception ex) { 151 152 StringBuilder sb = new StringBuilder(); 152 153 sb.Append("Sorry, but something went wrong!\n\n" + ex.Message + "\n\n" + ex.StackTrace); -
branches/PluginInfrastructure Refactoring/HeuristicLab.PluginInfrastructure/Starter/SplashScreen.Designer.cs
r2485 r2504 21 21 22 22 using HeuristicLab.PluginInfrastructure; 23 namespace HeuristicLab {23 namespace HeuristicLab.PluginInfrastructure { 24 24 partial class SplashScreen { 25 25 /// <summary> … … 39 39 base.Dispose(disposing); 40 40 } 41 41 42 42 43 43 #region Windows Form Designer generated code … … 191 191 this.pictureBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 192 192 | System.Windows.Forms.AnchorStyles.Left))); 193 this.pictureBox.Image = global::HeuristicLab.P roperties.Resources.Logo_white;193 this.pictureBox.Image = global::HeuristicLab.PluginInfrastructure.Properties.Resources.Logo_white; 194 194 this.pictureBox.Location = new System.Drawing.Point(-1, -1); 195 195 this.pictureBox.Name = "pictureBox"; -
branches/PluginInfrastructure Refactoring/HeuristicLab.PluginInfrastructure/Starter/SplashScreen.cs
r2497 r2504 29 29 using HeuristicLab.PluginInfrastructure.Manager; 30 30 31 namespace HeuristicLab {32 publicpartial class SplashScreen : Form {31 namespace HeuristicLab.PluginInfrastructure { 32 internal partial class SplashScreen : Form { 33 33 private const int FADE_INTERVAL = 50; 34 34 private System.Timers.Timer fadeTimer; 35 35 private int initialInterval; 36 36 private object bigLock = new object(); 37 private bool closing = false;37 private bool closing; 38 38 private PluginManager manager; 39 39 40 publicSplashScreen() {40 internal SplashScreen() { 41 41 InitializeComponent(); 42 42 } 43 43 44 publicSplashScreen(PluginManager manager, int initialInterval, string initialText)44 internal SplashScreen(PluginManager manager, int initialInterval, string initialText) 45 45 : this() { 46 46 this.initialInterval = initialInterval; … … 57 57 58 58 foreach (object obj in attributes) { 59 if (obj is AssemblyCopyrightAttribute) { 60 copyrightLabel.Text = "Copyright " + ((AssemblyCopyrightAttribute)obj).Copyright; 59 var attr = obj as AssemblyCopyrightAttribute; 60 if (attr != null) { 61 copyrightLabel.Text = "Copyright " + attr.Copyright; 61 62 } 62 63 } 63 64 64 try { 65 user = HeuristicLab.Properties.Settings.Default.User; 66 company = HeuristicLab.Properties.Settings.Default.Organization; 65 user = HeuristicLab.PluginInfrastructure.Properties.Settings.Default.User; 66 company = HeuristicLab.PluginInfrastructure.Properties.Settings.Default.Organization; 67 67 68 if ((user == null) || (user.Equals(""))) {69 70 71 72 68 if (string.IsNullOrEmpty(user)) { 69 userNameLabel.Text = "-"; 70 } else { 71 userNameLabel.Text = user; 72 } 73 73 74 if ((company == null) || (company.Equals(""))) { 75 companyLabel.Text = "-"; 76 } else { 77 companyLabel.Text = company; 78 } 79 } 80 catch (Exception) { 81 userNameLabel.Text = "-"; 74 if (string.IsNullOrEmpty(company)) { 82 75 companyLabel.Text = "-"; 76 } else { 77 companyLabel.Text = company; 83 78 } 84 79 } … … 88 83 } 89 84 90 p ublicvoid managerActionEventHandler(object sender, PluginInfrastructureEventArgs e) {85 private void managerActionEventHandler(object sender, PluginInfrastructureEventArgs e) { 91 86 string info = e.Action + ": " + e.Entity; 92 87 //if (e.Action == PluginManagerAction.Initializing) info = "Initializing ..."; -
branches/PluginInfrastructure Refactoring/HeuristicLab.PluginInfrastructure/app.config
r854 r2504 11 11 <value>plugins</value> 12 12 </setting> 13 <setting name="User" serializeAs="String"> 14 <value /> 15 </setting> 16 <setting name="Organization" serializeAs="String"> 17 <value /> 18 </setting> 13 19 </HeuristicLab.PluginInfrastructure.Properties.Settings> 14 20 </applicationSettings>
Note: See TracChangeset
for help on using the changeset viewer.