Example #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
}
Example #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")
}