1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | const constants_1 = require("../injector/constants");
|
4 | class ContextCreator {
|
5 | createContext(instance, callback, metadataKey, contextId = constants_1.STATIC_CONTEXT, inquirerId) {
|
6 | const globalMetadata = this.getGlobalMetadata &&
|
7 | this.getGlobalMetadata(contextId, inquirerId);
|
8 | const classMetadata = this.reflectClassMetadata(instance, metadataKey);
|
9 | const methodMetadata = this.reflectMethodMetadata(callback, metadataKey);
|
10 | return [
|
11 | ...this.createConcreteContext(globalMetadata || [], contextId, inquirerId),
|
12 | ...this.createConcreteContext(classMetadata, contextId, inquirerId),
|
13 | ...this.createConcreteContext(methodMetadata, contextId, inquirerId),
|
14 | ];
|
15 | }
|
16 | reflectClassMetadata(instance, metadataKey) {
|
17 | const prototype = Object.getPrototypeOf(instance);
|
18 | return Reflect.getMetadata(metadataKey, prototype.constructor);
|
19 | }
|
20 | reflectMethodMetadata(callback, metadataKey) {
|
21 | return Reflect.getMetadata(metadataKey, callback);
|
22 | }
|
23 | }
|
24 | exports.ContextCreator = ContextCreator;
|