di/registry/registry_test.go

46 lines
935 B
Go
Raw Normal View History

2017-12-05 13:28:42 +00:00
package registry
import (
2017-12-08 10:32:59 +00:00
"log"
2017-12-05 13:28:42 +00:00
"reflect"
"testing"
)
func TestRegisterType(t *testing.T) {
2017-12-08 10:32:59 +00:00
// 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)
}
2017-12-05 13:28:42 +00:00
}
2017-12-08 10:32:59 +00:00
type AService struct {
NameA string
2017-12-06 00:48:03 +00:00
}
2017-12-08 10:32:59 +00:00
type BService struct {
NameB string
2017-12-06 00:48:03 +00:00
}
2017-12-08 10:32:59 +00:00
type CService struct {
AService *AService `annotation:"@Inject()"`
BService *BService `annotation:"@Inject()"`
List []string `annotation:"@Resource()"`
2017-12-05 13:28:42 +00:00
}