@@ -247,6 +247,15 @@ export class Container {
247
247
return IoCContainer . get ( source ) ;
248
248
}
249
249
250
+ /**
251
+ * Retrieve a type associated with the type provided from the container
252
+ * @param source The dependency type to resolve
253
+ * @return an object resolved for the given source type;
254
+ */
255
+ static getType ( source : Function ) {
256
+ return IoCContainer . getType ( source ) ;
257
+ }
258
+
250
259
/**
251
260
* Store the state for a specified binding. Can then be restored later. Useful for testing.
252
261
* @param source The dependency type
@@ -308,6 +317,13 @@ class IoCContainer {
308
317
return config . getInstance ( ) ;
309
318
}
310
319
320
+ static getType ( source : Function ) : Function {
321
+ checkType ( source ) ;
322
+ const baseSource = InjectorHanlder . getConstructorFromType ( source ) ;
323
+ const config : ConfigImpl = IoCContainer . bindings . get ( baseSource ) ;
324
+ return config . targetSource || config . source ;
325
+ }
326
+
311
327
static injectProperty ( target : Function , key : string , propertyType : Function ) {
312
328
const propKey = `__${ key } ` ;
313
329
Object . defineProperty ( target . prototype , key , {
@@ -368,6 +384,7 @@ export interface Config {
368
384
369
385
class ConfigImpl implements Config {
370
386
source : Function ;
387
+ targetSource : Function ;
371
388
iocprovider : Provider ;
372
389
iocscope : Scope ;
373
390
decoratedConstructor : FunctionConstructor ;
@@ -380,6 +397,7 @@ class ConfigImpl implements Config {
380
397
to ( target : FunctionConstructor ) {
381
398
checkType ( target ) ;
382
399
const targetSource = InjectorHanlder . getConstructorFromType ( target ) ;
400
+ this . targetSource = targetSource ;
383
401
if ( this . source === targetSource ) {
384
402
const configImpl = this ;
385
403
this . iocprovider = {
0 commit comments