ResolveAll retrieves all instances assignable to the specified type.
(ctx context.Context, typ reflect.Type)
| 403 | |
| 404 | // ResolveAll retrieves all instances assignable to the specified type. |
| 405 | func (d *DefaultContainer) ResolveAll(ctx context.Context, typ reflect.Type) ([]any, error) { |
| 406 | if typ == nil { |
| 407 | return nil, errors.New("nil type") |
| 408 | } |
| 409 | |
| 410 | ctx = withCreationState(ctx) |
| 411 | |
| 412 | instances := d.findResolvableCandidates(typ) |
| 413 | |
| 414 | for _, def := range d.DefinitionsOf(typ) { |
| 415 | instance, err := d.Resolve(ctx, def.Name()) |
| 416 | |
| 417 | if err != nil { |
| 418 | return nil, err |
| 419 | } |
| 420 | |
| 421 | instances = append(instances, instance) |
| 422 | } |
| 423 | |
| 424 | return instances, nil |
| 425 | } |
| 426 | |
| 427 | // RegisterResolvable registers type with the corresponding value. |
| 428 | func (d *DefaultContainer) RegisterResolvable(typ reflect.Type, instance any) error { |
no test coverage detected