Documentation ¶
Index ¶
- type Creator
- type Injector
- func (i *Injector) AddCreator(creator Creator, alias string) error
- func (i *Injector) AddTypeValue(targetType interface{}, alias string) error
- func (i *Injector) AddValue(v interface{}, name string) error
- func (i *Injector) Resolve(nameOrAlias string, args interface{}) (interface{}, error)
- func (i *Injector) ResolveType(targetType interface{}, args interface{}) (interface{}, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Injector ¶
type Injector struct {
// contains filtered or unexported fields
}
func NewInjector ¶
func NewInjector() *Injector
func (*Injector) AddCreator ¶
AddCreator adds a creator for a giving reflect type which will return a value from the function everytime it's called. This can return a new value or the same, the creator decides that.
func (*Injector) AddTypeValue ¶
AddTypeValue works similar to Injector.AddValue and adds giving type which is used to generate a new type with the provided item supplied as the value of that type.
When you use a instance of that type, then the address of that instance is copied over and returned to you.
func (*Injector) AddValue ¶
AddValue registers a giving value as is based on the name provided. We treat the value as is and no operation is performed, whenever the name is resolved from the injector the value of v is always returned.
func (*Injector) Resolve ¶
Resolve allows resolution of a type based on name or alias which is used to execute the appropriate creator to create giving type.
func (*Injector) ResolveType ¶
ResolveType attempts resolving into a type based on the actual reflect type information from the provided type. It returns the result of the generator.