Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
03/15/12 09:11:17 (13 years ago)
Author:
gkronber
Message:

#1081 merged r7462:7609 from trunk into time series branch

Location:
branches/HeuristicLab.TimeSeries
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.TimeSeries

  • branches/HeuristicLab.TimeSeries/HeuristicLab.PluginInfrastructure/3.3/LightweightApplicationManager.cs

    r7268 r7615  
    7575      foreach (Type t in GetTypes(type)) {
    7676        object instance = null;
    77         try { instance = Activator.CreateInstance(t); }
    78         catch { }
     77        try { instance = Activator.CreateInstance(t); } catch { }
    7978        if (instance != null) instances.Add(instance);
    8079      }
     
    126125        var assemblyTypes = assembly.GetTypes();
    127126
    128         var buildTypes = from t in assemblyTypes
     127        var buildTypes = from t in assembly.GetTypes()
     128                         where CheckTypeCompatibility(type, t)
    129129                         where !IsNonDiscoverableType(t)
    130                          where CheckTypeCompatibility(type, t)
    131                          where onlyInstantiable == false || (!t.IsAbstract && !t.IsInterface && !t.HasElementType)
     130                         where onlyInstantiable == false ||
     131                               (!t.IsAbstract && !t.IsInterface && !t.HasElementType)
    132132                         select BuildType(t, type);
    133133
     
    135135               where includeGenericTypeDefinitions || !t.IsGenericTypeDefinition
    136136               select t;
    137       }
    138       catch (TypeLoadException) {
     137      } catch (TypeLoadException) {
    139138        return Enumerable.Empty<Type>();
    140       }
    141       catch (ReflectionTypeLoadException) {
     139      } catch (ReflectionTypeLoadException) {
    142140        return Enumerable.Empty<Type>();
    143141      }
     
    152150        return true;
    153151      if (type.IsGenericType && other.IsGenericType) {
     152        var otherGenericArguments = other.GetGenericArguments();
     153        var typeGenericArguments = type.GetGenericArguments();
     154
     155        //check type arguments count
     156        if (otherGenericArguments.Length != typeGenericArguments.Length)
     157          return false;
     158
     159        //check type arguments & constraints
     160        int i = 0;
     161        foreach (var genericArgument in typeGenericArguments) {
     162          if (otherGenericArguments[i].IsGenericParameter) {
     163            foreach (var constraint in otherGenericArguments[i].GetGenericParameterConstraints())
     164              if (!constraint.IsAssignableFrom(genericArgument)) return false;
     165          } else if (genericArgument != otherGenericArguments[i]) return false;
     166          i++;
     167        }
     168        //check types
    154169        try {
    155           if (type.IsAssignableFrom(other.GetGenericTypeDefinition().MakeGenericType(type.GetGenericArguments())))
     170          var otherGenericTypeDefinition = other.GetGenericTypeDefinition();
     171          if (type.IsAssignableFrom(otherGenericTypeDefinition.MakeGenericType(typeGenericArguments)))
    156172            return true;
    157         }
    158         catch (Exception) { }
     173        } catch (Exception) { }
    159174      }
    160175      return false;
Note: See TracChangeset for help on using the changeset viewer.