2.2.1
This commit is contained in:
parent
1335ea8be4
commit
36bb5d3123
3 changed files with 13 additions and 8 deletions
|
@ -1,3 +1,6 @@
|
|||
# 2.2.1
|
||||
* Explicit changes for assisting `angel_orm_generator`.
|
||||
|
||||
# 2.2.0
|
||||
* Build to `cache`.
|
||||
* Only generate one `.g.dart` file.
|
||||
|
|
|
@ -61,7 +61,7 @@ class SerializerGenerator extends GeneratorForAnnotation<Serializable> {
|
|||
..requiredParameters.add(new Parameter((b) {
|
||||
b
|
||||
..name = 'model'
|
||||
..type = ctx.modelClassType;
|
||||
..type = refer(ctx.originalClassName);
|
||||
}));
|
||||
|
||||
var buf = new StringBuffer();
|
||||
|
@ -90,10 +90,9 @@ class SerializerGenerator extends GeneratorForAnnotation<Serializable> {
|
|||
String serializedRepresentation = 'model.${field.name}';
|
||||
|
||||
String serializerToMap(ReCase rc, String value) {
|
||||
if (rc.pascalCase == ctx.modelClassName) {
|
||||
return '($value)?.toJson()';
|
||||
}
|
||||
|
||||
// if (rc.pascalCase == ctx.modelClassName) {
|
||||
// return '($value)?.toJson()';
|
||||
// }
|
||||
return '${rc.pascalCase}Serializer.toMap($value)';
|
||||
}
|
||||
|
||||
|
@ -110,10 +109,13 @@ class SerializerGenerator extends GeneratorForAnnotation<Serializable> {
|
|||
var t = field.type as InterfaceType;
|
||||
|
||||
if (isListOfModelType(t)) {
|
||||
//var rc = new ReCase(t.typeArguments[0].name);
|
||||
var name = t.typeArguments[0].name;
|
||||
if (name.startsWith('_')) name = name.substring(1);
|
||||
var rc = new ReCase(name);
|
||||
var m = serializerToMap(rc, 'm');
|
||||
serializedRepresentation = '''
|
||||
model.${field.name}
|
||||
?.map((m) => m.toJson())
|
||||
?.map((m) => $m)
|
||||
?.toList()''';
|
||||
} else if (isMapToModelType(t)) {
|
||||
var rc = new ReCase(t.typeArguments[1].name);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
name: angel_serialize_generator
|
||||
version: 2.2.0
|
||||
version: 2.2.1
|
||||
description: Model serialization generators, designed for use with Angel. Combine with angel_serialize for flexible modeling.
|
||||
author: Tobe O <thosakwe@gmail.com>
|
||||
homepage: https://github.com/angel-dart/serialize
|
||||
|
|
Loading…
Reference in a new issue