dart:mirrors
庫中MirrorsUsed.metaTargets
屬性的用法介紹如下。
用法:
dynamic
metaTargets
final
用作元數據時指示反射目標的類列表。另見targets。
以下文本是非規範性的:
指定類列表的格式與指定 targets 的格式相同。但是,由於庫不能用作 Dart 中的元數據注釋,因此將庫添加到 metaTargets 的列表中沒有任何效果。特別是,將庫添加到metaTargets 不會使庫的類成為有效的元數據注釋以啟用反射。
如果 metaTargets 中指定的類的實例用作庫、類、字段或方法的元數據注釋,則該庫、類、字段或方法將添加到反射目標集。
示例用法:
library example;
@MirrorsUsed(metaTargets: "example.Reflectable")
import "dart:mirrors";
class Reflectable {
const Reflectable();
}
class Foo {
@Reflectable()
reflectableMethod() { ... }
nonReflectableMethod() { ... }
}
在上麵的例子中。 reflectableMethod
使用Reflectable
類標記為可反射,而該類又在metaTargets 注釋中指定。
nonReflectableMethod
方法缺少元數據注釋,因此在運行時無法反映。
相關用法
- Dart MirrorsUsed.targets用法及代碼示例
- Dart MirrorsUsed.override用法及代碼示例
- Dart MirrorsUsed用法及代碼示例
- Dart MidiInputMap.clear用法及代碼示例
- Dart MidiInputMap.putIfAbsent用法及代碼示例
- Dart MimeTypeArray.first用法及代碼示例
- Dart MidiInputMap.containsKey用法及代碼示例
- Dart MidiInputMap.forEach用法及代碼示例
- Dart MidiOutputMap.forEach用法及代碼示例
- Dart MidiInputMap.remove用法及代碼示例
- Dart MidiOutputMap.containsKey用法及代碼示例
- Dart MidiInputMap.containsValue用法及代碼示例
- Dart MidiOutputMap.addAll用法及代碼示例
- Dart MidiOutputMap.containsValue用法及代碼示例
- Dart MidiOutputMap.remove用法及代碼示例
- Dart MimeTypeArray.last用法及代碼示例
- Dart MidiInputMap.addAll用法及代碼示例
- Dart MidiOutputMap.clear用法及代碼示例
- Dart MimeTypeArray.length用法及代碼示例
- Dart MimeTypeArray.elementAt用法及代碼示例
- Dart MidiOutputMap.putIfAbsent用法及代碼示例
- Dart MapMixin.containsKey用法及代碼示例
- Dart Map.update用法及代碼示例
- Dart Match.groups用法及代碼示例
- Dart MapEntry.value用法及代碼示例
注:本文由純淨天空篩選整理自dart.dev大神的英文原創作品 metaTargets property。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。