Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Holder ¶
type Holder interface {
Info() Info
Factory() Factory
GetInstance() (Instance, error)
NewRef(sel Selector) Ref
}
Holder 根据作用域,持有一个或一组组件实例
type Injection ¶
type Injection interface {
context.Context
Select(selector Selector) ([]Instance, error)
SelectOne(selector Selector) (Instance, error)
GetByID(id ID) (Instance, error)
GetProperty(selector Selector) (string, error)
GetWithHolder(holder Holder) (Instance, error)
Ext() InjectionExt
}
Injection 表示一个依赖注入上下文
type InjectionExt ¶
type InjectionExt interface {
Injection() Injection
GetString(selector Selector) string
GetBool(selector Selector) bool
GetRune(selector Selector) rune
GetByte(selector Selector) byte
GetInt(selector Selector) int
GetInt8(selector Selector) int8
GetInt16(selector Selector) int16
GetInt32(selector Selector) int32
GetInt64(selector Selector) int64
GetUint(selector Selector) uint
GetUint8(selector Selector) uint8
GetUint16(selector Selector) uint16
GetUint32(selector Selector) uint32
GetUint64(selector Selector) uint64
GetFloat32(selector Selector) float32
GetFloat64(selector Selector) float64
GetComponent(selector Selector) any
ListComponents(selector Selector) []any
}
InjectionExt 是 Injection 的扩展部分
type Registration ¶
type Registration struct {
ID ID
Classes string // 类名列表,项与项之间以空格符(SPACE)分隔
Aliases string // 别名列表,项与项之间以空格符(SPACE)分隔
Scope string // 作用域 'singleton'|'prototype'
NewFunc func() any
InjectFunc func(c Injection, instance any) error
}
Registration 组件注册信息
type Registry ¶
type Registry interface {
New() *Registration
Register(r *Registration)
}
Registry 提供组件注册服务
type RegistryHandlerFunc ¶
RegistryHandlerFunc 是组件注册的处理函数
Click to show internal directories.
Click to hide internal directories.