Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(117)

Unified Diff: third_party/pkg/di/lib/auto_injector.dart

Issue 257423008: Update all Angular libs (run update_all.sh). (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/pkg/di/lib/annotations.dart ('k') | third_party/pkg/di/lib/di.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/pkg/di/lib/auto_injector.dart
diff --git a/third_party/pkg/di/lib/auto_injector.dart b/third_party/pkg/di/lib/auto_injector.dart
new file mode 100644
index 0000000000000000000000000000000000000000..622ed25a93642df7814ac56f592704b30742948e
--- /dev/null
+++ b/third_party/pkg/di/lib/auto_injector.dart
@@ -0,0 +1,58 @@
+/**
+ * Library for using a pub transformer to automatically switch between
+ * dynamic and static injection.
+ *
+ * ## Step 1: Hook up the build step
+ * Edit ```pubspec.yaml``` to add the di transformer to the list of
+ * transformers.
+ *
+ * name: transformer_demo
+ * version: 0.0.1
+ * dependencies:
+ * di: any
+ * inject: any
+ * transformers:
+ * - di:
+ * dart_entry: web/main.dart
+ * injectable_annotations: transformer_demo.Injectable
+ *
+ * ## Step 2: Annotate your types
+ *
+ * class Engine {
+ * @inject
+ * Engine();
+ * }
+ *
+ * or
+ *
+ * @Injectable // custom annotation specified in pubspec.yaml
+ * class Car {}
+ *
+ *
+ * ## Step 3: Use the auto injector
+ * Modify your entry script to use [defaultInjector] as the injector.
+ *
+ * This must be done from the file registered as the dart_entry in pubspec.yaml
+ * as this is the only file which will be modified to include the generated
+ * injector.
+ *
+ * import 'package:di/auto_injector' as auto;
+ * main() {
+ * var injector = auto.defaultInjector(modules: ...);
+ * }
+ }
+ */
+library di.auto_injector;
+
+import 'package:di/di.dart';
+import 'package:di/dynamic_injector.dart';
+
+@MirrorsUsed(override: '*')
+import 'dart:mirrors' show MirrorsUsed;
+
+Injector defaultInjector({List<Module> modules, String name,
+ bool allowImplicitInjection: false}) =>
+ new DynamicInjector(
+ modules: modules,
+ name: name,
+ allowImplicitInjection: allowImplicitInjection);
« no previous file with comments | « third_party/pkg/di/lib/annotations.dart ('k') | third_party/pkg/di/lib/di.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698