Fix ListUserData erroring on type retrieval

This commit is contained in:
Deukhoofd 2019-01-26 14:08:18 +01:00
parent ee36060dd6
commit ce030c484f
No known key found for this signature in database
GPG Key ID: B4C087AC81641654
1 changed files with 18 additions and 6 deletions

View File

@ -20,14 +20,28 @@ namespace Upsilon.BaseTypes.UserData
{
List = list;
var type = list.GetType();
System.Type elementType;
if (type.IsArray)
{
TypeName = BoundTypeHandler.GetTypeName(type.GetElementType());
elementType = type.GetElementType();
TypeName = BoundTypeHandler.GetTypeName(elementType);
}
else
{
var generic = type.GetGenericArguments()[0];
TypeName = BoundTypeHandler.GetTypeName(generic);
elementType = type.GetGenericArguments()[0];
TypeName = BoundTypeHandler.GetTypeName(elementType);
}
if (TypeName == null)
{
Type = new CompositeTypeContainer(new TypeContainer[] {BaseTypes.Type.Number, new UndefinedUserDataTypeContainer(elementType)}
.ToImmutableArray());
}
else
{
Type = new CompositeTypeContainer(new TypeContainer[] {BaseTypes.Type.Number, new TypeContainer(TypeName)}
.ToImmutableArray());
}
}
@ -88,9 +102,7 @@ namespace Upsilon.BaseTypes.UserData
}
}
public override TypeContainer Type =>
new CompositeTypeContainer(new TypeContainer[] {BaseTypes.Type.Number, new TypeContainer(TypeName)}
.ToImmutableArray());
public override TypeContainer Type { get; }
public override object ToCSharpObject()
{
return List;