Dart API Referencedart:mirrorsInstanceMirror

InstanceMirror abstract class

An InstanceMirror reflects an instance of a Dart language object.

abstract class InstanceMirror implements ObjectMirror {
  /**
   * A mirror on the type of the reflectee.
   */
  ClassMirror get type;

  /**
   * Does [reflectee] contain the instance reflected by this mirror?
   * This will always be true in the local case (reflecting instances
   * in the same isolate), but only true in the remote case if this
   * mirror reflects a simple value.
   *
   * A value is simple if one of the following holds:
   *  - the value is null
   *  - the value is of type [num]
   *  - the value is of type [bool]
   *  - the value is of type [String]
   */
  bool get hasReflectee;

  /**
   * If the [InstanceMirror] reflects an instance it is meaningful to
   * have a local reference to, we provide access to the actual
   * instance here.
   *
   * If you access [reflectee] when [hasReflectee] is false, an
   * exception is thrown.
   */
  get reflectee;
}

Subclasses

ClosureMirror

Implements

ObjectMirror

Properties

final bool hasReflectee #

Does reflectee contain the instance reflected by this mirror? This will always be true in the local case (reflecting instances in the same isolate), but only true in the remote case if this mirror reflects a simple value.

A value is simple if one of the following holds: - the value is null - the value is of type num - the value is of type bool - the value is of type String

bool get hasReflectee;

final MirrorSystem mirrors #

inherited from Mirror

The MirrorSystem that contains this mirror.

MirrorSystem get mirrors;

final reflectee #

If the InstanceMirror reflects an instance it is meaningful to have a local reference to, we provide access to the actual instance here.

If you access reflectee when hasReflectee is false, an exception is thrown.

get reflectee;

final ClassMirror type #

A mirror on the type of the reflectee.

ClassMirror get type;

Methods

Future<InstanceMirror> getField(String fieldName) #

inherited from ObjectMirror

Invokes a getter and returns a mirror on the result. The getter can be the implicit getter for a field or a user-defined getter method.

TODO(turnidge): Handle ambiguous names.

Future<InstanceMirror> getField(String fieldName);

Future<InstanceMirror> invoke(String memberName, List<Object> positionalArguments, [Map<String, Object> namedArguments]) #

inherited from ObjectMirror

Invokes the named function and returns a mirror on the result.

TODO(turnidge): Properly document. TODO(turnidge): Handle ambiguous names. TODO(turnidge): Handle optional & named arguments.

Future<InstanceMirror> invoke(String memberName,
                              List<Object> positionalArguments,
                              [Map<String,Object> namedArguments]);

Future<InstanceMirror> setField(String fieldName, Object value) #

inherited from ObjectMirror

Invokes a setter and returns a mirror on the result. The setter may be either the implicit setter for a non-final field or a user-defined setter method.

TODO(turnidge): Handle ambiguous names.

Future<InstanceMirror> setField(String fieldName, Object value);