Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
08/28/12 13:11:15 (12 years ago)
Author:
mkommend
Message:

#1919: Refactored calculation of thresholds for SymbolicDiscriminantFunctionClassficationModels and removed the automatic recalculation of thresholds during solution creation.

Location:
trunk/sources/HeuristicLab.PluginInfrastructure/3.3
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.PluginInfrastructure/3.3/LightweightApplicationManager.cs

    r7662 r8531  
    7575      foreach (Type t in GetTypes(type)) {
    7676        object instance = null;
    77         try { instance = Activator.CreateInstance(t); } catch { }
     77        try { instance = Activator.CreateInstance(t); }
     78        catch { }
    7879        if (instance != null) instances.Add(instance);
    7980      }
     
    137138               where includeGenericTypeDefinitions || !t.IsGenericTypeDefinition
    138139               select t;
    139       } catch (TypeLoadException) {
     140      }
     141      catch (TypeLoadException) {
    140142        return Enumerable.Empty<Type>();
    141       } catch (ReflectionTypeLoadException) {
     143      }
     144      catch (ReflectionTypeLoadException) {
    142145        return Enumerable.Empty<Type>();
    143146      }
     
    163166        foreach (var genericArgument in typeGenericArguments) {
    164167          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
    165176            foreach (var constraint in otherGenericArguments[i].GetGenericParameterConstraints())
    166177              if (!constraint.IsAssignableFrom(genericArgument)) return false;
     
    173184          if (type.IsAssignableFrom(otherGenericTypeDefinition.MakeGenericType(typeGenericArguments)))
    174185            return true;
    175         } catch (Exception) { }
     186        }
     187        catch (Exception) { }
    176188      }
    177189      return false;
  • trunk/sources/HeuristicLab.PluginInfrastructure/3.3/SandboxApplicationManager.cs

    r7586 r8531  
    293293        foreach (var genericArgument in typeGenericArguments) {
    294294          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
    295303            foreach (var constraint in otherGenericArguments[i].GetGenericParameterConstraints())
    296304              if (!constraint.IsAssignableFrom(genericArgument)) return false;
Note: See TracChangeset for help on using the changeset viewer.