1 | import * as DI from './di'
|
2 | import {repositoryMap} from '../core/exports'
|
3 | import {ClassType} from '../core/utils/classtype';
|
4 |
|
5 | let repoSource = function (target: ClassType<any>) {
|
6 | let repo;
|
7 | if (!target) {
|
8 | return null;
|
9 | }
|
10 | Object.keys(repositoryMap())
|
11 | .forEach(x => {
|
12 |
|
13 | var path;
|
14 | if (target.prototype) {
|
15 | path = target.prototype.path;
|
16 | }
|
17 | else if (target['default']) {
|
18 | path = target['default'].prototype.path;
|
19 | }
|
20 | if (path === x) {
|
21 | repo = repositoryMap()[x].repo;
|
22 | }
|
23 |
|
24 |
|
25 |
|
26 | });
|
27 | return repo;
|
28 | }
|
29 |
|
30 | DI.Container.addSource(repoSource);
|
31 |
|
32 | export let Container: DI.IContainer = DI.Container;
|