Detect model class
This commit is contained in:
parent
acce9a4bb8
commit
236ef55230
2 changed files with 17 additions and 0 deletions
|
@ -21,4 +21,15 @@ TypeReference convertTypeReference(DartType t) {
|
|||
b.types.addAll(t.typeArguments.map(convertTypeReference));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
bool isModelClass(DartType t) {
|
||||
if (serializableTypeChecker.hasAnnotationOf(t.element))
|
||||
return true;
|
||||
|
||||
if (t is InterfaceType) {
|
||||
return isModelClass(t.superclass);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -72,9 +72,15 @@ class SerializerGenerator extends GeneratorForAnnotation<Serializable> {
|
|||
|
||||
String serializedRepresentation = field.name;
|
||||
|
||||
// Serialize dates
|
||||
if (dateTimeTypeChecker.isAssignableFromType(field.type))
|
||||
serializedRepresentation = '${field.name}.toIso8601String()';
|
||||
|
||||
// Serialize model classes via `XSerializer.toMap`
|
||||
else if (isModelClass(field.type)) {
|
||||
|
||||
}
|
||||
|
||||
buf.write("'$alias': $serializedRepresentation");
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue