| OLD | NEW |
| (Empty) |
| 1 /** | |
| 2 * Library for using a pub transformer to automatically switch between | |
| 3 * dynamic and static injection. | |
| 4 * | |
| 5 * ## Step 1: Hook up the build step | |
| 6 * Edit ```pubspec.yaml``` to add the di transformer to the list of | |
| 7 * transformers. | |
| 8 * | |
| 9 * name: transformer_demo | |
| 10 * version: 0.0.1 | |
| 11 * dependencies: | |
| 12 * di: any | |
| 13 * inject: any | |
| 14 * transformers: | |
| 15 * - di: | |
| 16 * dart_entry: web/main.dart | |
| 17 * injectable_annotations: transformer_demo.Injectable | |
| 18 * | |
| 19 * ## Step 2: Annotate your types | |
| 20 * | |
| 21 * class Engine { | |
| 22 * @inject | |
| 23 * Engine(); | |
| 24 * } | |
| 25 * | |
| 26 * or | |
| 27 * | |
| 28 * @Injectable // custom annotation specified in pubspec.yaml | |
| 29 * class Car {} | |
| 30 * | |
| 31 * | |
| 32 * ## Step 3: Use the auto injector | |
| 33 * Modify your entry script to use [defaultInjector] as the injector. | |
| 34 * | |
| 35 * This must be done from the file registered as the dart_entry in pubspec.yaml | |
| 36 * as this is the only file which will be modified to include the generated | |
| 37 * injector. | |
| 38 * | |
| 39 * import 'package:di/auto_injector' as auto; | |
| 40 * main() { | |
| 41 * var injector = auto.defaultInjector(modules: ...); | |
| 42 * } | |
| 43 } | |
| 44 */ | |
| 45 library di.auto_injector; | |
| 46 | |
| 47 import 'package:di/di.dart'; | |
| 48 import 'package:di/dynamic_injector.dart'; | |
| 49 | |
| 50 @MirrorsUsed(override: '*') | |
| 51 import 'dart:mirrors' show MirrorsUsed; | |
| 52 | |
| 53 Injector defaultInjector({List<Module> modules, String name, | |
| 54 bool allowImplicitInjection: false}) => | |
| 55 new DynamicInjector( | |
| 56 modules: modules, | |
| 57 name: name, | |
| 58 allowImplicitInjection: allowImplicitInjection); | |
| OLD | NEW |