Comparing version 0.0.4 to 0.0.5
@@ -11,2 +11,5 @@ require('reflect-metadata'); | ||
}; | ||
Container.registerDefaultInitializationParameter = function (type, params) { | ||
this.defaultParameters.push({ type: type, params: params }); | ||
}; | ||
Container.get = function (type, params) { | ||
@@ -16,2 +19,7 @@ var obj = this.findInstanceOfType(type); | ||
return obj; | ||
if (!params) { | ||
var defaultParams = this.defaultParameters.reduce(function (found, i) { return i.type === type ? i : found; }, undefined); | ||
if (defaultParams) | ||
params = defaultParams.params; | ||
} | ||
if (params) { | ||
@@ -25,2 +33,5 @@ params = this.mapParams(type, params); | ||
}; | ||
Container.set = function (type, value) { | ||
this.instances.push({ type: type, instance: value }); | ||
}; | ||
// ------------------------------------------------------------------------- | ||
@@ -41,3 +52,3 @@ // Private Static Methods | ||
return paramHandler.getValue(); | ||
return Container.get(param, Reflect.getMetadata('design:paramtypes', param)); | ||
return Container.get(param); //, Reflect.getMetadata('design:paramtypes', param)); | ||
}); | ||
@@ -50,4 +61,5 @@ }; | ||
Container.customParamHandlers = []; | ||
Container.defaultParameters = []; | ||
return Container; | ||
})(); | ||
exports.Container = Container; |
{ | ||
"name": "typedi", | ||
"version": "0.0.4", | ||
"version": "0.0.5", | ||
"description": "Dependancy injection for Typescript", | ||
@@ -5,0 +5,0 @@ "license": "Apache-2.0", |
@@ -12,6 +12,9 @@ declare module 'typedi/Container' { | ||
export class Container { | ||
static instances: Instance[]; | ||
static customParamHandlers: CustomParamHandler[]; | ||
private static instances; | ||
private static customParamHandlers; | ||
private static defaultParameters; | ||
static registerCustomParamHandler(paramHandler: CustomParamHandler): void; | ||
static registerDefaultInitializationParameter(type: Function, params?: any[]): void; | ||
static get<T>(type: Function, params?: any[]): T; | ||
static set(type: Function, value: any): void; | ||
private static findInstanceOfType(type); | ||
@@ -35,1 +38,5 @@ private static findCustomParamHandler(type, index); | ||
} | ||
declare module 'typedi/Service' { | ||
export function Service(): (target: Function) => void; | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
8969
8
143