di/registry/registry_test.go
crusader c6d6690cee ing
2017-12-08 19:32:59 +09:00

46 lines
935 B
Go

package registry
import (
"log"
"reflect"
"testing"
)
func TestRegisterType(t *testing.T) {
// RegisterType(reflect.TypeOf((*TestStruct1)(nil)), &cda.ComponentAnnotation{})
// RegisterType(reflect.TypeOf((*TestStruct2)(nil)), &cda.ComponentAnnotation{
// Name: "test1",
// })
// RegisterType(reflect.TypeOf((*TestStruct3)(nil)), &cda.ComponentAnnotation{
// Name: "test2",
// })
// fs := getFields(reflect.TypeOf((*TestStruct3)(nil)))
// log.Printf("%v", fs)
RegisterResource("List", []string{"dfdkf", "skgkfg"})
i, err := GetInstance(reflect.TypeOf((*CService)(nil)))
if nil != err {
log.Printf("%v", err)
} else {
cs := i.(*CService)
log.Printf("%v", cs)
}
}
type AService struct {
NameA string
}
type BService struct {
NameB string
}
type CService struct {
AService *AService `annotation:"@Inject()"`
BService *BService `annotation:"@Inject()"`
List []string `annotation:"@Resource()"`
}