Better handling of getting valid bound type.
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Immutable;
|
||||
using System.Diagnostics;
|
||||
using Upsilon.BoundTypes;
|
||||
|
||||
namespace Upsilon.BaseTypes
|
||||
|
||||
@@ -61,7 +61,12 @@ namespace Upsilon.BoundTypes
|
||||
}
|
||||
|
||||
var bDef = TypeDefinitions.FirstOrDefault(x =>
|
||||
x.Value.ValidInternalTypes.Any(validType => validType.IsAssignableFrom(type)));
|
||||
{
|
||||
var first = x.Value.ValidInternalTypes.FirstOrDefault();
|
||||
if (first == null)
|
||||
return false;
|
||||
return first.IsAssignableFrom(type);
|
||||
});
|
||||
if (!bDef.Equals(default(KeyValuePair<string, BoundTypeDefinition>)))
|
||||
{
|
||||
TypeLookup.TryAdd(type, bDef.Key);
|
||||
|
||||
@@ -44,6 +44,8 @@ namespace Upsilon.BoundTypes
|
||||
// We don't want the global object type to be returned
|
||||
if (currentBaseType == typeof(object))
|
||||
break;
|
||||
if (currentBaseType == typeof(ValueType))
|
||||
break;
|
||||
yield return currentBaseType;
|
||||
currentBaseType = currentBaseType.BaseType;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user