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