Update file service generator
This commit is contained in:
parent
96f2955e94
commit
fda5f94469
1 changed files with 19 additions and 8 deletions
|
@ -14,18 +14,29 @@ class FileServiceGenerator extends ServiceGenerator {
|
||||||
bool get goesFirst => true;
|
bool get goesFirst => true;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void applyToLibrary(LibraryBuilder library, String name, String lower) {
|
void applyToConfigureServer(MethodBuilder configureServer, BlockBuilder block,
|
||||||
library.addMember(new ImportBuilder('dart:io'));
|
String name, String lower) {
|
||||||
library.addMember(new ImportBuilder(
|
configureServer.requiredParameters.add(new Parameter((b) => b
|
||||||
'package:angel_file_service/angel_file_service.dart'));
|
..name = 'dbDirectory'
|
||||||
|
..type = refer('Directory')));
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
ExpressionBuilder createInstance(
|
void applyToLibrary(LibraryBuilder library, String name, String lower) {
|
||||||
|
library.directives.addAll([
|
||||||
|
new Directive.import(
|
||||||
|
'package:angel_file_service/angel_file_service.dart'),
|
||||||
|
new Directive.import('package:file/file.dart'),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Expression createInstance(
|
||||||
MethodBuilder methodBuilder, String name, String lower) {
|
MethodBuilder methodBuilder, String name, String lower) {
|
||||||
return new TypeBuilder('JsonFileService').newInstance([
|
return refer('JsonFileService').newInstance([
|
||||||
new TypeBuilder('File')
|
refer('dbDirectory')
|
||||||
.newInstance([literal(pluralize(lower) + '_db.json')])
|
.property('childFile')
|
||||||
|
.call([literal(pluralize(lower) + '_db.json')])
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue