Changeset 2592 for trunk/sources/HeuristicLab.PluginInfrastructure
- Timestamp:
- 01/05/10 11:07:21 (15 years ago)
- Location:
- trunk/sources/HeuristicLab.PluginInfrastructure
- Files:
-
- 7 edited
- 3 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.PluginInfrastructure/ApplicationManager.cs
r2527 r2592 138 138 /// </summary> 139 139 /// <param name="plugins">bytearray of all assemblies that should be loaded</param> 140 publicvoid LoadAssemblies(IEnumerable<byte[]> assemblies) {140 internal void LoadAssemblies(IEnumerable<byte[]> assemblies) { 141 141 foreach (byte[] asm in assemblies) { 142 142 Assembly loadedAsm = Assembly.Load(asm); … … 156 156 /// <typeparam name="T">Most general type.</typeparam> 157 157 /// <returns>Enumerable of the created instances.</returns> 158 publicstatic IEnumerable<T> GetInstances<T>(IPluginDescription plugin) where T : class {158 internal static IEnumerable<T> GetInstances<T>(IPluginDescription plugin) where T : class { 159 159 return from t in GetTypes(typeof(T), plugin) 160 160 select (T)Activator.CreateInstance(t); … … 175 175 /// <typeparam name="T">Most general type.</typeparam> 176 176 /// <returns>Enumerable of the created instances.</returns> 177 publicstatic IEnumerable<T> GetInstances<T>() where T : class {177 internal static IEnumerable<T> GetInstances<T>() where T : class { 178 178 return from i in GetInstances(typeof(T)) 179 179 select (T)i; … … 185 185 /// <typeparam name="type">Most general type.</typeparam> 186 186 /// <returns>Enumerable of the created instances.</returns> 187 publicstatic IEnumerable<object> GetInstances(Type type) {187 internal static IEnumerable<object> GetInstances(Type type) { 188 188 return from t in GetTypes(type) 189 189 select Activator.CreateInstance(t); … … 195 195 /// <param name="type">Most general type for which to find matching types.</param> 196 196 /// <returns>Enumerable of the discovered types.</returns> 197 publicstatic IEnumerable<Type> GetTypes(Type type) {197 internal static IEnumerable<Type> GetTypes(Type type) { 198 198 return from asm in AppDomain.CurrentDomain.GetAssemblies() 199 199 from t in GetTypes(type, asm) … … 208 208 /// <param name="plugin">The plugin the subtypes must be part of.</param> 209 209 /// <returns>Enumerable of the discovered types.</returns> 210 publicstatic IEnumerable<Type> GetTypes(Type type, IPluginDescription pluginDescription) {210 internal static IEnumerable<Type> GetTypes(Type type, IPluginDescription pluginDescription) { 211 211 PluginDescription pluginDesc = (PluginDescription)pluginDescription; 212 212 return from asm in AppDomain.CurrentDomain.GetAssemblies() … … 252 252 #region IApplicationManager Members 253 253 254 255 254 IEnumerable<T> IApplicationManager.GetInstances<T>(IPluginDescription plugin) { 256 255 return GetInstances<T>(plugin); … … 261 260 } 262 261 262 IEnumerable<object> IApplicationManager.GetInstances(Type type) { 263 return GetInstances(type); 264 } 265 263 266 IEnumerable<Type> IApplicationManager.GetTypes(Type type) { 264 267 return GetTypes(type); … … 269 272 } 270 273 274 /// <summary> 275 /// Finds the plugin that declares the <paramref name="type">type</paramref>. 276 /// </summary> 277 /// <param name="type">The type of interest.</param> 278 /// <returns>The description of the plugin that declares the given type or null if the type has not been declared by a known plugin.</returns> 279 public IPluginDescription GetDeclaringPlugin(Type type) { 280 foreach (PluginDescription info in Plugins) { 281 if (info.Assemblies.Contains(Path.GetFullPath(type.Assembly.Location))) return info; 282 } 283 return null; 284 } 271 285 #endregion 272 286 } -
trunk/sources/HeuristicLab.PluginInfrastructure/BaseClasses/PluginBase.cs
r2504 r2592 35 35 /// Initializes a new instance of <see cref="PluginBase"/>. 36 36 /// </summary> 37 p rotectedPluginBase() { }37 public PluginBase() { } 38 38 39 39 private PluginAttribute PluginAttribute { -
trunk/sources/HeuristicLab.PluginInfrastructure/HeuristicLab.PluginInfrastructure.csproj
r2527 r2592 149 149 <DesignTimeSharedInput>True</DesignTimeSharedInput> 150 150 </Compile> 151 <Compile Include="Sandboxing\ISandboxManager.cs" /> 152 <Compile Include="Sandboxing\SandboxManager.cs" /> 151 153 <Compile Include="Service References\UpdateLocationReference\Reference.cs"> 152 154 <AutoGen>True</AutoGen> -
trunk/sources/HeuristicLab.PluginInfrastructure/Interfaces/IApplicationManager.cs
r2504 r2592 41 41 42 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>46 void LoadAssemblies(IEnumerable<byte[]> assemblies);47 48 /// <summary>49 43 /// 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 44 /// </summary> … … 61 55 62 56 /// <summary> 57 /// Discovers and creates instances of <paramref name="type"/> and all types implementing or inheriting <paramref name="type"/> (directly and indirectly). 58 /// </summary> 59 /// <param name="type">The type or super-type to discover.</typeparam> 60 /// <returns>An enumerable of instances of the discovered types.</returns> 61 IEnumerable<object> GetInstances(Type type); 62 63 /// <summary> 63 64 /// Discovers all types implementing or inheriting <paramref name="type"/> (directly and indirectly). 64 65 /// </summary> … … 73 74 /// <returns>An enumerable of discovered types.</returns> 74 75 IEnumerable<Type> GetTypes(Type type, IPluginDescription plugin); 76 /// <summary> 77 /// Finds the plugin that declares the <paramref name="type">type</paramref>. 78 /// </summary> 79 /// <param name="type">The type of interest.</param> 80 /// <returns>The description of the plugin that declares the given type or null if the type has not been declared by a known plugin.</returns> 81 IPluginDescription GetDeclaringPlugin(Type type); 75 82 } 76 83 } -
trunk/sources/HeuristicLab.PluginInfrastructure/Interfaces/IPluginDescription.cs
r2504 r2592 32 32 /// </summary> 33 33 string Name { get; } 34 /// <summary> 35 /// Gets the version of the plugin. 36 /// </summary> 37 Version Version { get; } 38 /// <summary> 39 /// Gets the build date of the plugin. 40 /// </summary> 41 DateTime BuildDate { get; } 42 /// <summary> 43 /// Gets the dependencies of the plugin. 44 /// </summary> 45 IEnumerable<IPluginDescription> Dependencies { get; } 46 /// <summary> 47 /// Gets the file names of files that are part of the plugin. 48 /// </summary> 49 IEnumerable<string> Files { get; } 34 50 } 35 51 } -
trunk/sources/HeuristicLab.PluginInfrastructure/Manager/PluginDescription.cs
r2517 r2592 23 23 using System.Collections.Generic; 24 24 using System.Text; 25 using System.Linq; 25 26 26 27 namespace HeuristicLab.PluginInfrastructure.Manager { … … 35 36 private string name; 36 37 /// <summary> 37 /// Gets or setsthe name of the plugin.38 /// Gets the name of the plugin. 38 39 /// </summary> 39 40 public string Name { … … 52 53 private Version version; 53 54 /// <summary> 54 /// Gets or setsthe version of the plugin.55 /// Gets the version of the plugin. 55 56 /// </summary> 56 internalVersion Version {57 public Version Version { 57 58 get { return version; } 58 set { version = value; }59 internal set { version = value; } 59 60 } 60 61 private DateTime buildDate; 61 62 /// <summary> 62 /// Gets or setsthe build date of the plugin.63 /// Gets the build date of the plugin. 63 64 /// </summary> 64 internalDateTime BuildDate {65 public DateTime BuildDate { 65 66 get { return buildDate; } 66 set { buildDate = value; }67 internal set { buildDate = value; } 67 68 } 68 69 … … 81 82 /// These files are deleted when the plugin is removed or updated. 82 83 /// </summary> 83 internalIEnumerable<string> Files {84 public IEnumerable<string> Files { 84 85 get { return files; } 85 86 } … … 90 91 91 92 private List<PluginDescription> dependencies = new List<PluginDescription>(); 93 internal IEnumerable<PluginDescription> Dependencies { 94 get { return dependencies; } 95 } 92 96 /// <summary> 93 97 /// Gets all dependencies of the plugin. 94 98 /// </summary> 95 internal IEnumerable<PluginDescription>Dependencies {96 get { return dependencies ; }99 IEnumerable<IPluginDescription> IPluginDescription.Dependencies { 100 get { return dependencies.Cast<IPluginDescription>(); } 97 101 } 98 102 … … 100 104 dependencies.Add(dependency); 101 105 } 102 103 106 104 107 private List<string> assemblies = new List<string>(); -
trunk/sources/HeuristicLab.PluginInfrastructure/Manager/PluginManager.cs
r2527 r2592 112 112 113 113 /// <summary> 114 /// Starts an dapplication in a separate AppDomain.115 /// Loads all enabled plugins and starts the application via a PluginRunner instance activated in the new AppDomain.114 /// Starts an application in a separate AppDomain. 115 /// Loads all enabled plugins and starts the application via an ApplicationManager instance activated in the new AppDomain. 116 116 /// </summary> 117 117 /// <param name="appInfo">application to run</param>
Note: See TracChangeset
for help on using the changeset viewer.