This commit is contained in:
Byung Jun Park 2017-07-26 00:39:03 +09:00
parent 478d99e732
commit 83858415f7
2 changed files with 11 additions and 11 deletions

View File

@ -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);
}
};
};

View File

@ -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();