Theo69
(Theo)
December 21, 2020, 9:43am
1
In island, the Type type has no property IsPrimitive .
What means that I can not use the following (that I can do in .Net):
Dim IsStructure = myType.IsValueType AndAlso Not mtType.IsPrimitive AndAlso Not mtType.IsEnum
How can I check if a type is a structure?
mh
(marc hoffman)
December 21, 2020, 2:20pm
2
I don’t believe you can. Whats the context here, that this wouldn’t be known when writing the code, is myType
generic?
Theo69
(Theo)
December 21, 2020, 3:46pm
4
I need this information to build a Serializer / DeSerializer.
I can see if something is a string (special case)
I can see if something is a reference object
I can see if something is an Enum
and then, everything else is unknown (a value type), but for a structure I need a complete other flow than for a primitive type.
ck
(Carlo Kok)
December 21, 2020, 6:39pm
5
You can use the code property (might be type code) to differentiate primitive types. Note that in this context, object and string are primitive too. But combined with is value type that should be solvable.
Theo69
(Theo)
December 23, 2020, 11:19am
6
@ck I was thinking - a primitive does not have a constructor.
Does a structure has one? because then constructor + valuetype = struct
ck
(Carlo Kok)
December 23, 2020, 11:56am
7
Primitives have an implied constructor that returns default().
1 Like