arguments returns the list of resolved arguments for a function.
(function interface{})
| 111 | |
| 112 | // arguments returns the list of resolved arguments for a function. |
| 113 | func (c Container) arguments(function interface{}) ([]reflect.Value, error) { |
| 114 | reflectedFunction := reflect.TypeOf(function) |
| 115 | argumentsCount := reflectedFunction.NumIn() |
| 116 | arguments := make([]reflect.Value, argumentsCount) |
| 117 | |
| 118 | for i := 0; i < argumentsCount; i++ { |
| 119 | abstraction := reflectedFunction.In(i) |
| 120 | if concrete, exist := c[abstraction][""]; exist { |
| 121 | instance, err := concrete.make(c) |
| 122 | if err != nil { |
| 123 | return nil, err |
| 124 | } |
| 125 | arguments[i] = reflect.ValueOf(instance) |
| 126 | } else { |
| 127 | return nil, errors.New("container: no concrete found for: " + abstraction.String()) |
| 128 | } |
| 129 | } |
| 130 | |
| 131 | return arguments, nil |
| 132 | } |
| 133 | |
| 134 | // Reset deletes all the existing bindings and empties the container. |
| 135 | func (c Container) Reset() { |