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