Changeset 3821 for trunk/sources/HeuristicLab.PluginInfrastructure
- Timestamp:
- 05/17/10 02:00:58 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.PluginInfrastructure/DefaultApplicationManager.cs
r3247 r3821 240 240 private static IEnumerable<Type> GetTypes(Type type, Assembly assembly, bool onlyInstantiable) { 241 241 return from t in assembly.GetTypes() 242 where type.IsAssignableFrom(t)242 where CheckTypeCompatibility(type, t) 243 243 where onlyInstantiable == false || (!t.IsAbstract && !t.IsInterface && !t.HasElementType) 244 select t; 244 select BuildType(type, t); 245 } 246 247 private static bool CheckTypeCompatibility(Type type, Type other) { 248 if (type.IsAssignableFrom(other)) 249 return true; 250 if (type.IsGenericType && other.IsGenericType) { 251 try { 252 if (type.IsAssignableFrom(other.GetGenericTypeDefinition().MakeGenericType(type.GetGenericArguments()))) 253 return true; 254 } catch (Exception) { } 255 } 256 return false; 257 } 258 private static Type BuildType(Type type, Type other) { 259 if (type.IsGenericType && other.IsGenericType) 260 return other.GetGenericTypeDefinition().MakeGenericType(type.GetGenericArguments()); 261 else 262 return other; 245 263 } 246 264
Note: See TracChangeset
for help on using the changeset viewer.