ing
This commit is contained in:
parent
64af0e5f73
commit
70018c51f5
|
@ -33,16 +33,15 @@ func (td *TypeDefinition) GetAnnotationByType(at reflect.Type, includeEmbedding
|
|||
}
|
||||
|
||||
for _, v := range td.TypeAnnotations {
|
||||
if at == reflect.TypeOf(v) {
|
||||
return v
|
||||
}
|
||||
|
||||
if includeEmbedding {
|
||||
if checkAnnotation(reflect.TypeOf(v), at) {
|
||||
return v
|
||||
}
|
||||
} else {
|
||||
if at == reflect.TypeOf(v) {
|
||||
return v
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return nil
|
||||
|
@ -87,6 +86,26 @@ func (fd *FieldDefinition) GetAnnotation(name string) cda.Annotation {
|
|||
return fd.Annotations[name]
|
||||
}
|
||||
|
||||
func (fd *FieldDefinition) GetAnnotationByType(at reflect.Type, includeEmbedding bool) cda.Annotation {
|
||||
if nil == fd.Annotations {
|
||||
return nil
|
||||
}
|
||||
|
||||
for _, v := range fd.Annotations {
|
||||
if at == reflect.TypeOf(v) {
|
||||
return v
|
||||
}
|
||||
|
||||
if includeEmbedding {
|
||||
if checkAnnotation(reflect.TypeOf(v), at) {
|
||||
return v
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func FullName(pkgName, typeName string) string {
|
||||
return fmt.Sprintf("%s/%s", pkgName, typeName)
|
||||
}
|
||||
|
|
|
@ -149,12 +149,11 @@ func (cr *defaultComponentRegistry) GetInstance(t reflect.Type) interface{} {
|
|||
logging.Logger().Panic(fmt.Sprintf("DI: Field[%s] can not set", fd.FieldName))
|
||||
}
|
||||
|
||||
annotation = fd.GetAnnotation(cdia.InjectTag)
|
||||
if nil != annotation {
|
||||
if annotation = fd.GetAnnotationByType(reflect.TypeOf((*cdia.Inject)(nil)), false); nil != annotation {
|
||||
fV = cr.GetInstance(fd.Type)
|
||||
}
|
||||
annotation = fd.GetAnnotation(cdia.ResourceTag)
|
||||
if nil != annotation {
|
||||
|
||||
if annotation = fd.GetAnnotationByType(reflect.TypeOf((*cdia.Resource)(nil)), false); nil != annotation {
|
||||
n := annotation.(*cdia.Resource).Name
|
||||
if "" == n {
|
||||
n = fd.FieldName
|
||||
|
|
Loading…
Reference in New Issue
Block a user