Changeset 3828 for trunk/sources/HeuristicLab.PluginInfrastructure
- Timestamp:
- 05/17/10 23:27:03 (15 years ago)
- Location:
- trunk/sources/HeuristicLab.PluginInfrastructure
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.PluginInfrastructure/DefaultApplicationManager.cs
r3821 r3828 242 242 where CheckTypeCompatibility(type, t) 243 243 where onlyInstantiable == false || (!t.IsAbstract && !t.IsInterface && !t.HasElementType) 244 select BuildType(t ype, t);244 select BuildType(t, type); 245 245 } 246 246 … … 256 256 return false; 257 257 } 258 private static Type BuildType(Type type, Type other) {259 if (type.IsGenericType && other.IsGenericType)260 return other.GetGenericTypeDefinition().MakeGenericType(type.GetGenericArguments());258 private static Type BuildType(Type type, Type protoType) { 259 if (type.IsGenericType && protoType.IsGenericType) 260 return type.GetGenericTypeDefinition().MakeGenericType(protoType.GetGenericArguments()); 261 261 else 262 return other;262 return type; 263 263 } 264 264 -
trunk/sources/HeuristicLab.PluginInfrastructure/LightweightApplicationManager.cs
r3247 r3828 109 109 private static IEnumerable<Type> GetTypes(Type type, Assembly assembly, bool onlyInstantiable) { 110 110 return from t in assembly.GetTypes() 111 where type.IsAssignableFrom(t)111 where CheckTypeCompatibility(type, t) 112 112 where onlyInstantiable == false || (!t.IsAbstract && !t.IsInterface && !t.HasElementType) 113 select t; 113 select BuildType(t, type); 114 } 115 116 private static bool CheckTypeCompatibility(Type type, Type other) { 117 if (type.IsAssignableFrom(other)) 118 return true; 119 if (type.IsGenericType && other.IsGenericType) { 120 try { 121 if (type.IsAssignableFrom(other.GetGenericTypeDefinition().MakeGenericType(type.GetGenericArguments()))) 122 return true; 123 } 124 catch (Exception) { } 125 } 126 return false; 127 } 128 private static Type BuildType(Type type, Type protoType) { 129 if (type.IsGenericType && protoType.IsGenericType) 130 return type.GetGenericTypeDefinition().MakeGenericType(protoType.GetGenericArguments()); 131 else 132 return type; 114 133 } 115 134
Note: See TracChangeset
for help on using the changeset viewer.