1 | "use strict";
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 | Object.defineProperty(exports, "__esModule", { value: true });
|
11 | exports.inject = void 0;
|
12 |
|
13 |
|
14 |
|
15 | function inject(value) {
|
16 |
|
17 | function decorator(target, propertyKey) {
|
18 | |
19 |
|
20 |
|
21 | if (!propertyKey) {
|
22 | if (!target.hasOwnProperty('inject')) {
|
23 | Object.defineProperty(target, 'inject', {
|
24 | value: {},
|
25 | });
|
26 | }
|
27 | target.inject.instance = target.inject.instance || [];
|
28 | const constructorParams = Reflect.getMetadata('design:paramtypes', target);
|
29 | if (constructorParams) {
|
30 | constructorParams.forEach((param, index) => {
|
31 | if (value && value[index]) {
|
32 | target.inject.instance.push(value[index]);
|
33 | }
|
34 | else {
|
35 | target.inject.instance.push(param);
|
36 | }
|
37 | });
|
38 | }
|
39 | return;
|
40 | }
|
41 | |
42 |
|
43 |
|
44 | if (!target.constructor.hasOwnProperty('inject')) {
|
45 | Object.defineProperty(target.constructor, 'inject', {
|
46 | value: {},
|
47 | });
|
48 | }
|
49 | target.constructor.inject[propertyKey] = target.constructor.inject[propertyKey] || [];
|
50 | const methodParams = Reflect.getMetadata('design:paramtypes', target, propertyKey);
|
51 | if (methodParams) {
|
52 | methodParams.forEach((param, index) => {
|
53 | if (value && value[index]) {
|
54 | target.constructor.inject[propertyKey].push(value[index]);
|
55 | }
|
56 | else {
|
57 | target.constructor.inject[propertyKey].push(param);
|
58 | }
|
59 | });
|
60 | }
|
61 | }
|
62 | return decorator;
|
63 | }
|
64 | exports.inject = inject;
|