Merge "Add presingletons" am: 62255a7687
am: a0f01cda41
am: 127149ea12
Change-Id: I81be21021cf4e46d68d928552f129b60017e705f
This commit is contained in:
commit
72db101636
|
@ -31,6 +31,7 @@ type singleton struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
var singletons []singleton
|
var singletons []singleton
|
||||||
|
var preSingletons []singleton
|
||||||
|
|
||||||
type mutator struct {
|
type mutator struct {
|
||||||
name string
|
name string
|
||||||
|
@ -60,6 +61,10 @@ func RegisterSingletonType(name string, factory blueprint.SingletonFactory) {
|
||||||
singletons = append(singletons, singleton{name, factory})
|
singletons = append(singletons, singleton{name, factory})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func RegisterPreSingletonType(name string, factory blueprint.SingletonFactory) {
|
||||||
|
preSingletons = append(preSingletons, singleton{name, factory})
|
||||||
|
}
|
||||||
|
|
||||||
type Context struct {
|
type Context struct {
|
||||||
*blueprint.Context
|
*blueprint.Context
|
||||||
}
|
}
|
||||||
|
@ -69,6 +74,10 @@ func NewContext() *Context {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ctx *Context) Register() {
|
func (ctx *Context) Register() {
|
||||||
|
for _, t := range preSingletons {
|
||||||
|
ctx.RegisterPreSingletonType(t.name, t.factory)
|
||||||
|
}
|
||||||
|
|
||||||
for _, t := range moduleTypes {
|
for _, t := range moduleTypes {
|
||||||
ctx.RegisterModuleType(t.name, t.factory)
|
ctx.RegisterModuleType(t.name, t.factory)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue