- Timestamp:
- 10/01/19 14:29:59 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3026_IntegrationIntoSymSpace/HeuristicLab.Manufacture/Extensions/TypeExtensions.cs
r17269 r17282 8 8 namespace HeuristicLab.Manufacture { 9 9 public static class TypeExtensions { 10 public static int GetInterfaceDistance(this Type type, Type interfaceType) {11 if (!interfaceType.IsInterface) return -1;12 int distance = int.MaxValue;13 Type baseType = type;14 while (baseType != typeof(object)) {15 var interfaces = baseType.GetInterfaces();16 var minimalInterfaces = interfaces.Except(interfaces.SelectMany(i => i.GetInterfaces()));17 if (minimalInterfaces.Any(i => {18 if (i.IsGenericType)19 return i.GetGenericTypeDefinition() == interfaceType;20 return i == interfaceType;21 })) --distance;22 baseType = baseType.BaseType;23 }24 return distance;25 }26 10 27 11 public static bool IsEqualTo(this Type type, Type other) {
Note: See TracChangeset
for help on using the changeset viewer.