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 }
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") }
func RegRepo(agg Agg, repo Repo) { aggMap[di.Ptr2Elem(reflect.TypeOf(agg))] = reflect.TypeOf(repo) }