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