Documentation
¶
Index ¶
- Variables
- type DIGo
- type DImpl
- func (this *DImpl) BindFunc(fn interface{})
- func (di *DImpl) FillClass(classPtr interface{}) (err error)
- func (di *DImpl) InvokeFunc(fn interface{}) (fnOut []interface{}, err error)
- func (di *DImpl) InvokePtr(ptr interface{}) (err error)
- func (di *DImpl) MapSingleton(T Type, V Value) (err error)
- func (di *DImpl) Singleton(instancePtr interface{}) (err error)
- func (di *DImpl) SingletonFunc(fn interface{}) (err error)
- type Hook
- type Kind
- type Type
- type Value
Constants ¶
This section is empty.
Variables ¶
View Source
var ( TypeOf = reflect.TypeOf ValueOf = reflect.ValueOf )
View Source
var (
ErrNotBound = errors.New(`build not-bound types`)
)
Functions ¶
This section is empty.
Types ¶
type DIGo ¶
type DIGo interface {
// 注册单例
//
// s := new(T)
// di.Singleton(s)
Singleton(instancePtr interface{}) (err error)
// 通过闭包方式注册
// 闭包的第一个返回值的类型作为注册的 T
// 闭包的参数,会根据类型从容器中取数据
//
// di.SingletonFunc(func(a *A) (T) {
// // a will build first
// return T{}
// })
SingletonFunc(fn interface{}) (err error)
// MapSingleton 表示从接口到实体的映射
//
// di.MapSingleton(op.Writer, os.Stdout)
MapSingleton(T Type, V Value) (err error)
// 利用容器提供的默认数据赋值
// ptr := new(T)
// di.Build(ptr)
InvokePtr(ptr interface{}) (err error)
// 利用容器提供的默认数据调用函数
// di.Invoke(func(a *A, b *B) {
// // a, b built
// }
InvokeFunc(fn interface{}) (fnOut []interface{}, err error)
// 利用容器提供的默认数据填充对象的成员
//
//
FillClass(classPtr interface{}) (err error)
}
type DImpl ¶
type DImpl struct {
// contains filtered or unexported fields
}
func NewDiGoImpl ¶
func NewDiGoImpl() *DImpl
func (*DImpl) InvokeFunc ¶
func (*DImpl) SingletonFunc ¶
Click to show internal directories.
Click to hide internal directories.