-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontainerCore.go
59 lines (48 loc) · 1.19 KB
/
containerCore.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package di
import (
"reflect"
"sync"
)
type deflist []*Def
func (e deflist) Len() int {
return len(e)
}
func (e deflist) Less(i, j int) bool {
return e[i].Name > e[j].Name
}
func (e deflist) Swap(i, j int) {
e[i], e[j] = e[j], e[i]
}
// containerCore contains the data of a Container.
// But it can not build objects on its own.
// It should be used inside a container.
type containerCore struct {
m sync.RWMutex
closed bool
scope string
scopes ScopeList
definitions DefMap
parent *containerCore
children map[*containerCore]struct{}
unscopedChild *containerCore
objects map[objectKey]interface{}
lastUniqueID int
deleteIfNoChild bool
dependencies *graph
typeDefMap map[reflect.Type]deflist
}
func (ctn *containerCore) Definitions() map[string]Def {
return ctn.definitions.Copy()
}
func (ctn *containerCore) Scope() string {
return ctn.scope
}
func (ctn *containerCore) Scopes() []string {
return ctn.scopes.Copy()
}
func (ctn *containerCore) ParentScopes() []string {
return ctn.scopes.ParentScopes(ctn.scope)
}
func (ctn *containerCore) SubScopes() []string {
return ctn.scopes.SubScopes(ctn.scope)
}