2018-08-21 02:44:32 +00:00
|
|
|
import 'package:angel_container/angel_container.dart';
|
2016-09-15 19:53:01 +00:00
|
|
|
|
2017-11-28 18:14:50 +00:00
|
|
|
final RegExp straySlashes = new RegExp(r'(^/+)|(/+$)');
|
|
|
|
|
2018-08-21 02:44:32 +00:00
|
|
|
matchingAnnotation(List<ReflectedInstance> metadata, Type T) {
|
|
|
|
for (ReflectedInstance metaDatum in metadata) {
|
|
|
|
if (metaDatum.type == T) {
|
|
|
|
return metaDatum.reflectee;
|
2016-09-15 19:53:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2018-08-21 02:44:32 +00:00
|
|
|
getAnnotation(obj, Type T, Reflector reflector) {
|
|
|
|
if (reflector == null) {
|
|
|
|
return null;
|
2016-09-15 19:53:01 +00:00
|
|
|
} else {
|
2018-08-21 02:44:32 +00:00
|
|
|
if (obj is Function) {
|
|
|
|
var methodMirror = reflector.reflectFunction(obj);
|
|
|
|
return matchingAnnotation(methodMirror.annotations, T);
|
|
|
|
} else {
|
|
|
|
var classMirror = reflector.reflectClass(obj.runtimeType as Type);
|
|
|
|
return matchingAnnotation(classMirror.annotations, T);
|
|
|
|
}
|
2016-09-15 19:53:01 +00:00
|
|
|
}
|
2017-09-22 14:03:23 +00:00
|
|
|
}
|