resolveAll<T> method
Resolves all registered implementations of a given type.
Note: This implementation has a bug - it tries to resolve T for all registered types, which will likely fail. This should be fixed to properly resolve all implementations that are assignable to T.
Implementation
@override
List<T> resolveAll<T>() {
final result = <T>[];
void addIfMissing(T value) {
if (!result.contains(value)) {
result.add(value);
}
}
for (final instance in _instances.values) {
if (instance is T) {
addIfMissing(instance);
}
}
for (final type in _bindings.keys.toList()) {
try {
final resolved = resolveType(type);
if (resolved is T) {
addIfMissing(resolved);
}
} catch (_) {
// Skip unresolved bindings and continue collecting valid services.
}
}
for (final entry in _contextualBindings.entries) {
final context = entry.key;
final bindings = entry.value;
for (final type in bindings.keys.toList()) {
try {
final resolved = resolveType(type, context);
if (resolved is T) {
addIfMissing(resolved);
}
} catch (_) {
// Skip unresolved contextual bindings.
}
}
}
return List<T>.unmodifiable(result);
}