resolve method

Object resolve(
  1. Type targetType
)

Resolve a type registered with the contianer specified by targetType.

Implementation

Object resolve(Type targetType) {
  if (!_dependencyRegistrations
      .any((r) => identical(r.typeRegistered, targetType))) {
    throw StateError('The type ' +
        targetType.toString() +
        ' is not registered with the IoC container.');
  }

  var registration = _dependencyRegistrations
      .singleWhere((r) => identical(r.typeRegistered, targetType));

  if (registration.registrationType ==
      _RegistrationType.instanceRegistration) {
    return registration.registeredInstance;
  } else {
    return registration.factoryMethod();
  }
}