di/annotation/resource.go

36 lines
467 B
Go
Raw Normal View History

2017-12-05 10:02:41 +00:00
package annotation
2017-12-05 13:28:42 +00:00
import "strings"
const (
ResourceTag = "@Resource"
)
2017-12-05 10:02:41 +00:00
type Resource struct {
2017-12-05 13:28:42 +00:00
Annotation
2017-12-05 10:02:41 +00:00
Name string
}
2017-12-05 13:28:42 +00:00
func ParseResource(a string) (*Resource, error) {
i := strings.Index(a, ResourceTag)
if -1 == i {
return nil, nil
}
inject := &Resource{}
atts, err := ParseAttribute(a, i+len(ResourceTag))
if nil != err {
return nil, err
}
for k, v := range atts {
switch k {
case "name":
inject.Name = v
}
}
return inject, nil
}