ing
This commit is contained in:
parent
478d99e732
commit
83858415f7
|
@ -11,19 +11,17 @@ const inject = (config?: Config) => {
|
|||
if (typeof parameterIndex === 'number') {
|
||||
// tagParameter(target, targetKey, index, metadata);
|
||||
} else {
|
||||
let meta: Map<string | symbol, Config>;
|
||||
if (Reflect.hasOwnMetadata(METADATA.INJECT_TAG, target)) {
|
||||
let meta = Reflect.getMetadata(METADATA.INJECT_TAG, target);
|
||||
meta = Reflect.getMetadata(METADATA.INJECT_TAG, target);
|
||||
} else {
|
||||
let meta: string[];
|
||||
meta = new Map();
|
||||
Reflect.defineMetadata(METADATA.INJECT_TAG, meta, target);
|
||||
}
|
||||
|
||||
|
||||
let types = Reflect.getMetadata(METADATA.INJECT_TAG, target);
|
||||
|
||||
// Reflect.defineMetadata(METADATA.PARAM_TYPES, types, target);
|
||||
|
||||
console.log(types);
|
||||
// tagProperty(target, targetKey, metadata);
|
||||
if (meta.has(propertyKey)) {
|
||||
throw new Error('Cannot apply @injectable decorator multiple times.');
|
||||
}
|
||||
meta.set(propertyKey, config);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
|
|
@ -18,7 +18,9 @@ class AppContext {
|
|||
}
|
||||
|
||||
public static getService<T>(clazz: {new(...args: any[]): T}): T {
|
||||
let types = Reflect.getMetadata(METADATA.PARAM_TYPES, clazz);
|
||||
let s = Object.getPrototypeOf(clazz.prototype);
|
||||
let types1 = Reflect.getMetadata(METADATA.INJECT_TAG, s);
|
||||
let types2 = Reflect.getMetadata(METADATA.INJECT_TAG, clazz);
|
||||
|
||||
let i = new clazz();
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user