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

Side by Side Diff: third_party/pkg/angular/lib/core/registry.dart

Issue 124053002: Adding Angular and dependent packages for testing (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 11 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 part of angular.core;
2
3 abstract class AnnotationMap<K> {
4 final Map<K, Type> _map = {};
5
6 AnnotationMap(Injector injector, MetadataExtractor extractMetadata) {
7 injector.types.forEach((type) {
8 var meta = extractMetadata(type)
9 .where((annotation) => annotation is K)
10 .forEach((annotation) {
11 if (_map.containsKey(annotation)) {
12 var annotationType = K;
13 throw "Duplicate annotation found: $annotationType: $annotation. " +
14 "Exisitng: ${_map[annotation]}; New: $type.";
15 }
16 _map[annotation] = type;
17 });
18 });
19 }
20
21 Type operator[](K annotation) {
22 var value = _map[annotation];
23 if (value == null) {
24 throw 'No $annotation found!';
25 }
26 return value;
27 }
28
29 forEach(fn(K, Type)) => _map.forEach(fn);
30
31 List<K> annotationsFor(Type type) {
32 var res = <K>[];
33 forEach((ann, annType) {
34 if (annType == type) {
35 res.add(ann);
36 }
37 });
38 return res;
39 }
40 }
41
42 @NgInjectableService()
43 class MetadataExtractor {
44
45 Iterable call(Type type) {
46 var metadata = reflectClass(type).metadata;
47 if (metadata == null) return [];
48 return metadata.map((InstanceMirror im) => im.reflectee);
49 }
50 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698