Changeset 8531 for trunk/sources/HeuristicLab.PluginInfrastructure
- Timestamp:
- 08/28/12 13:11:15 (12 years ago)
- Location:
- trunk/sources/HeuristicLab.PluginInfrastructure/3.3
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.PluginInfrastructure/3.3/LightweightApplicationManager.cs
r7662 r8531 75 75 foreach (Type t in GetTypes(type)) { 76 76 object instance = null; 77 try { instance = Activator.CreateInstance(t); } catch { } 77 try { instance = Activator.CreateInstance(t); } 78 catch { } 78 79 if (instance != null) instances.Add(instance); 79 80 } … … 137 138 where includeGenericTypeDefinitions || !t.IsGenericTypeDefinition 138 139 select t; 139 } catch (TypeLoadException) { 140 } 141 catch (TypeLoadException) { 140 142 return Enumerable.Empty<Type>(); 141 } catch (ReflectionTypeLoadException) { 143 } 144 catch (ReflectionTypeLoadException) { 142 145 return Enumerable.Empty<Type>(); 143 146 } … … 163 166 foreach (var genericArgument in typeGenericArguments) { 164 167 if (otherGenericArguments[i].IsGenericParameter) { 168 //check class contraint on generic type parameter 169 if (otherGenericArguments[i].GenericParameterAttributes.HasFlag(GenericParameterAttributes.ReferenceTypeConstraint)) 170 if (!genericArgument.IsClass) return false; 171 172 //check default constructor constraint on generic type parameter 173 if (otherGenericArguments[i].GenericParameterAttributes.HasFlag(GenericParameterAttributes.DefaultConstructorConstraint)) 174 if (!genericArgument.IsValueType && genericArgument.GetConstructor(Type.EmptyTypes) == null) return false; 175 165 176 foreach (var constraint in otherGenericArguments[i].GetGenericParameterConstraints()) 166 177 if (!constraint.IsAssignableFrom(genericArgument)) return false; … … 173 184 if (type.IsAssignableFrom(otherGenericTypeDefinition.MakeGenericType(typeGenericArguments))) 174 185 return true; 175 } catch (Exception) { } 186 } 187 catch (Exception) { } 176 188 } 177 189 return false; -
trunk/sources/HeuristicLab.PluginInfrastructure/3.3/SandboxApplicationManager.cs
r7586 r8531 293 293 foreach (var genericArgument in typeGenericArguments) { 294 294 if (otherGenericArguments[i].IsGenericParameter) { 295 //check class contraint on generic type parameter 296 if (otherGenericArguments[i].GenericParameterAttributes.HasFlag(GenericParameterAttributes.ReferenceTypeConstraint)) 297 if (!genericArgument.IsClass) return false; 298 299 //check default constructor constraint on generic type parameter 300 if (otherGenericArguments[i].GenericParameterAttributes.HasFlag(GenericParameterAttributes.DefaultConstructorConstraint)) 301 if (!genericArgument.IsValueType && genericArgument.GetConstructor(Type.EmptyTypes) == null) return false; 302 295 303 foreach (var constraint in otherGenericArguments[i].GetGenericParameterConstraints()) 296 304 if (!constraint.IsAssignableFrom(genericArgument)) return false;
Note: See TracChangeset
for help on using the changeset viewer.