Free cookie consent management tool by TermsFeed Policy Generator

source: branches/3026_IntegrationIntoSymSpace/HeuristicLab.Manufacture/Util.cs @ 17263

Last change on this file since 17263 was 17263, checked in by dpiringe, 5 years ago

#3026:

  • added first prototype for:
    • creating templates
    • initialize a optimizer out of a template
  • first attempts to create the option to extend the template generation and initialisation (with Transformers -> json To IItem, IItem to json) without serializing/deserializing the whole IItem
File size: 862 bytes
Line 
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
5using System.Threading.Tasks;
6using HeuristicLab.Core;
7
8namespace ParameterTest {
9  public class Util {
10    public static bool IsTypeOf(object obj, Type t) {
11      if (obj == null || t == null) return false;
12      Type objType = obj.GetType();
13      if (t.IsInterface && t.IsGenericType)
14        return (objType == t || objType.IsAssignableFrom(t) || objType.GetInterfaces().Where(i => i.IsGenericType).Any(i => i.GetGenericTypeDefinition() == t));
15      if (t.IsGenericType) {
16        Type baseType = objType;
17        while (baseType != typeof(object)) {
18          if (baseType.IsGenericType && baseType.GetGenericTypeDefinition() == t) return true;
19          baseType = baseType.BaseType;
20        }
21      }
22      return objType == t;
23    }
24  }
25}
Note: See TracBrowser for help on using the repository browser.