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

Side by Side Diff: third_party/pkg/di/lib/static_injector.dart

Issue 107003007: Adding Angular's DI package & Dart unittests which test it. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « third_party/pkg/di/lib/reflected_type.dart ('k') | third_party/pkg/di/package.json » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 library di.static_injector;
2
3 import 'di.dart';
4
5 typedef Object TypeFactory(factory(Type));
6
7 /**
8 * Static implementation of [Injector] that uses type factories
9 */
10 class StaticInjector extends Injector {
11 Map<Type, TypeFactory> typeFactories;
12
13 StaticInjector({List<Module> modules, String name,
14 bool allowImplicitInjection: false, this.typeFactories})
15 : super(modules: modules, name: name,
16 allowImplicitInjection: allowImplicitInjection);
17
18 StaticInjector._fromParent(List<Module> modules, Injector parent, {name})
19 : super.fromParent(modules, parent, name: name);
20
21 newFromParent(List<Module> modules, String name) {
22 return new StaticInjector._fromParent(modules, this, name: name);
23 }
24
25 Object newInstanceOf(Type type, ObjectFactory getInstanceByType,
26 Injector requestor, error) {
27 TypeFactory typeFactory = (root as StaticInjector).typeFactories[type];
28 if (typeFactory == null) {
29 throw new NoProviderError(error('No type factory provided for $type!'));
30 }
31 return typeFactory((type) => getInstanceByType(type, requestor));
32 }
33 }
OLDNEW
« no previous file with comments | « third_party/pkg/di/lib/reflected_type.dart ('k') | third_party/pkg/di/package.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698