34 lines
574 B
Go
34 lines
574 B
Go
|
package annotation
|
||
|
|
||
|
import (
|
||
|
"reflect"
|
||
|
|
||
|
cdur "git.loafle.net/commons_go/di/util/reflect"
|
||
|
)
|
||
|
|
||
|
var annotationRegistry map[string]*AnnotationDefinition
|
||
|
|
||
|
func init() {
|
||
|
annotationRegistry = make(map[string]*AnnotationDefinition, 0)
|
||
|
}
|
||
|
|
||
|
func RegisterAnnotation(name string, t reflect.Type) {
|
||
|
meta := getMetaFields(t)
|
||
|
fRT, _, _ := cdur.GetTypeInfo(t)
|
||
|
|
||
|
def := &AnnotationDefinition{
|
||
|
t: t,
|
||
|
rt: fRT,
|
||
|
fields: meta,
|
||
|
}
|
||
|
|
||
|
annotationRegistry[name] = def
|
||
|
}
|
||
|
|
||
|
type AnnotationDefinition struct {
|
||
|
t reflect.Type
|
||
|
rt reflect.Type
|
||
|
|
||
|
fields map[string]*AnnotationFieldMeta
|
||
|
}
|