Exemplo n.º 1
0
func getRepoByAgg(aggType reflect.Type) (Repo, bool) {
	if repoType, ok := aggMap[di.Ptr2Elem(aggType)]; ok {
		if repo := di.Get(repoType); repo.IsValid() {
			if r := repo.Interface().(Repo); r != nil {
				return r, true
			}
		}
	}
	return nil, false
}
Exemplo n.º 2
0
func Load(aggType reflect.Type, id GUID) (Agg, error) {
	if repoType, ok := aggMap[di.Ptr2Elem(aggType)]; ok {
		if repo := di.Get(repoType); repo.IsValid() {
			r := repo.Interface().(Repo)
			agg := reflect.New(aggType).Interface().(Agg)
			r.GetAs(id, agg.Root())
			return agg, nil
		}
	}
	return nil, errors.New("error")
}
Exemplo n.º 3
0
func RegRepo(agg Agg, repo Repo) {
	aggMap[di.Ptr2Elem(reflect.TypeOf(agg))] = reflect.TypeOf(repo)
}