Index: third_party/pkg/angular/lib/change_detection/dirty_checking_change_detector_dynamic.dart |
diff --git a/third_party/pkg/angular/lib/change_detection/dirty_checking_change_detector_dynamic.dart b/third_party/pkg/angular/lib/change_detection/dirty_checking_change_detector_dynamic.dart |
new file mode 100644 |
index 0000000000000000000000000000000000000000..bc03d013dee5219f2da396b99a50eebdfd99d065 |
--- /dev/null |
+++ b/third_party/pkg/angular/lib/change_detection/dirty_checking_change_detector_dynamic.dart |
@@ -0,0 +1,35 @@ |
+library dirty_checking_change_detector_dynamic; |
+ |
+import 'package:angular/change_detection/change_detection.dart'; |
+export 'package:angular/change_detection/change_detection.dart' show |
+ FieldGetterFactory; |
+ |
+/** |
+ * We are using mirrors, but there is no need to import anything. |
+ */ |
+@MirrorsUsed(targets: const [ DynamicFieldGetterFactory ], metaTargets: const [] ) |
+import 'dart:mirrors'; |
+ |
+class DynamicFieldGetterFactory implements FieldGetterFactory { |
+ final isMethodInvoke = true; |
+ |
+ isMethod(Object object, String name) { |
+ var declaration = reflectClass(object.runtimeType).declarations[new Symbol(name)]; |
+ return declaration != null && |
+ declaration is MethodMirror && |
+ (declaration as MethodMirror).isRegularMethod; |
+ } |
+ |
+ Function method(Object object, String name) { |
+ Symbol symbol = new Symbol(name); |
+ InstanceMirror instanceMirror = reflect(object); |
+ return (List args, Map namedArgs) => |
+ instanceMirror.invoke(symbol, args, namedArgs).reflectee; |
+ } |
+ |
+ FieldGetter getter(Object object, String name) { |
+ Symbol symbol = new Symbol(name); |
+ InstanceMirror instanceMirror = reflect(object); |
+ return (Object object) => instanceMirror.getField(symbol).reflectee; |
+ } |
+} |