MCPcopy Create free account
hub / github.com/golobby/container / arguments

Method arguments

container.go:113–132  ·  view source on GitHub ↗

arguments returns the list of resolved arguments for a function.

(function interface{})

Source from the content-addressed store, hash-verified

111
112// arguments returns the list of resolved arguments for a function.
113func (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.
135func (c Container) Reset() {

Callers 2

invokeMethod · 0.95
CallMethod · 0.95

Calls 1

makeMethod · 0.80

Tested by

no test coverage detected