Changeset 7111 for trunk/sources/HeuristicLab.PluginInfrastructure/3.3/LightweightApplicationManager.cs
- Timestamp:
- 12/01/11 17:33:56 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.PluginInfrastructure/3.3/LightweightApplicationManager.cs
r7069 r7111 73 73 public IEnumerable<object> GetInstances(Type type) { 74 74 List<object> instances = new List<object>(); 75 foreach (Type t in GetTypes(type , true)) {75 foreach (Type t in GetTypes(type)) { 76 76 object instance = null; 77 77 try { instance = Activator.CreateInstance(t); } … … 88 88 /// <remarks>Return only types that are instantiable 89 89 /// (interfaces, abstract classes... are not returned)</remarks> 90 /// <param name="includeGenericTypeDefinitions">Specifies if generic type definitions shall be included</param> 90 91 /// <returns>Enumerable of the discovered types.</returns> 91 public IEnumerable<Type> GetTypes(IEnumerable<Type> types, bool onlyInstantiable = true, bool assignableToAllTypes = true) {92 IEnumerable<Type> result = GetTypes(types.First(), onlyInstantiable );92 public IEnumerable<Type> GetTypes(IEnumerable<Type> types, bool onlyInstantiable = true, bool includeGenericTypeDefinitions = false, bool assignableToAllTypes = true) { 93 IEnumerable<Type> result = GetTypes(types.First(), onlyInstantiable, includeGenericTypeDefinitions); 93 94 foreach (Type type in types.Skip(1)) { 94 IEnumerable<Type> discoveredTypes = GetTypes(type, onlyInstantiable );95 IEnumerable<Type> discoveredTypes = GetTypes(type, onlyInstantiable, includeGenericTypeDefinitions); 95 96 if (assignableToAllTypes) result = result.Intersect(discoveredTypes); 96 97 else result = result.Union(discoveredTypes); … … 105 106 /// <param name="onlyInstantiable">Return only types that are instantiable 106 107 /// (interfaces, abstract classes... are not returned)</param> 108 /// <param name="includeGenericTypeDefinitions">Specifies if generic type definitions shall be included</param> 107 109 /// <returns>Enumerable of the discovered types.</returns> 108 public IEnumerable<Type> GetTypes(Type type, bool onlyInstantiable = true ) {110 public IEnumerable<Type> GetTypes(Type type, bool onlyInstantiable = true, bool includeGenericTypeDefinitions = false) { 109 111 return from asm in AppDomain.CurrentDomain.GetAssemblies() 110 from t in GetTypes(type, asm, onlyInstantiable )112 from t in GetTypes(type, asm, onlyInstantiable, includeGenericTypeDefinitions) 111 113 select t; 112 114 } … … 120 122 /// (interfaces, abstract classes... are not returned)</param> 121 123 /// <returns>Enumerable of the discovered types.</returns> 122 private static IEnumerable<Type> GetTypes(Type type, Assembly assembly, bool onlyInstantiable = true ) {124 private static IEnumerable<Type> GetTypes(Type type, Assembly assembly, bool onlyInstantiable = true, bool includeGenericTypeDefinitions = false) { 123 125 try { 124 126 var assemblyTypes = assembly.GetTypes(); … … 131 133 132 134 return from t in buildTypes 133 where onlyInstantiable == false|| !t.IsGenericTypeDefinition135 where includeGenericTypeDefinitions || !t.IsGenericTypeDefinition 134 136 select t; 135 137 } … … 182 184 /// <param name="plugin"></param> 183 185 /// <param name="onlyInstantiable"></param> 184 /// <returns></returns> 185 /// <throws>NotSupportedException</throws> 186 public IEnumerable<Type> GetTypes(Type type, IPluginDescription plugin, bool onlyInstantiable = true) { 186 /// <param name="includeGenericTypeDefinitions"></param> 187 /// <returns></returns> 188 /// <throws>NotSupportedException</throws> 189 public IEnumerable<Type> GetTypes(Type type, IPluginDescription plugin, bool onlyInstantiable = true, bool includeGenericTypeDefinitions = false) { 187 190 throw new NotSupportedException("LightweightApplicationManager doesn't support type discovery for plugins."); 188 191 } … … 194 197 /// <param name="plugin"></param> 195 198 /// <param name="onlyInstantiable"></param> 196 /// <returns></returns> 197 /// <throws>NotSupportedException</throws> 198 public IEnumerable<Type> GetTypes(IEnumerable<Type> types, IPluginDescription plugin, bool onlyInstantiable = true, bool assignableToAllTypes = true) { 199 /// <param name="includeGenericTypeDefinitions"></param> 200 /// <returns></returns> 201 /// <throws>NotSupportedException</throws> 202 public IEnumerable<Type> GetTypes(IEnumerable<Type> types, IPluginDescription plugin, bool onlyInstantiable = true, bool includeGenericTypeDefinitions = false, bool assignableToAllTypes = true) { 199 203 throw new NotSupportedException("LightweightApplicationManager doesn't support type discovery for plugins."); 200 204 }
Note: See TracChangeset
for help on using the changeset viewer.