@@ -2,35 +2,35 @@ import { InstanceFactory } from './container-types';
22import { BuildContext } from '../model' ;
33
44const BUILD_CONTEXT_KEY = '__BuildContext' ;
5- const BLOCK_INSTANTIATION_KEY = '__block_Instantiation' ;
65const IOC_WRAPPER_CLASS = 'ioc_wrapper' ;
76
87/**
98 * Utility class to handle injection behavior on class decorations.
109 */
1110export class InjectorHandler {
1211 public static constructorNameRegEx = / f u n c t i o n ( \w * ) / ;
12+ private static instantiationsBlocked = true ;
13+
1314
1415 public static instrumentConstructor ( source : Function ) {
1516 let newConstructor : any ;
1617 // tslint:disable-next-line:class-name
1718 newConstructor = class ioc_wrapper extends ( source as FunctionConstructor ) {
1819 constructor ( ...args : Array < any > ) {
1920 super ( ...args ) ;
20- InjectorHandler . assertInstantiable ( source ) ;
21+ InjectorHandler . assertInstantiable ( ) ;
2122 }
2223 } ;
2324 newConstructor [ '__parent' ] = source ;
24- InjectorHandler . blockInstantiation ( source ) ;
2525 return newConstructor ;
2626 }
2727
28- public static blockInstantiation ( source : Function ) {
29- source [ BLOCK_INSTANTIATION_KEY ] = true ;
28+ public static blockInstantiation ( ) {
29+ InjectorHandler . instantiationsBlocked = true ;
3030 }
3131
32- public static unblockInstantiation ( source : Function ) {
33- source [ BLOCK_INSTANTIATION_KEY ] = false ;
32+ public static unblockInstantiation ( ) {
33+ InjectorHandler . instantiationsBlocked = false ;
3434 }
3535
3636 public static getConstructorFromType ( target : Function ) : FunctionConstructor {
@@ -92,8 +92,8 @@ export class InjectorHandler {
9292 }
9393 }
9494
95- private static assertInstantiable ( target : any ) {
96- if ( target [ BLOCK_INSTANTIATION_KEY ] ) {
95+ private static assertInstantiable ( ) {
96+ if ( InjectorHandler . instantiationsBlocked ) {
9797 throw new TypeError ( 'Can not instantiate it. The instantiation is blocked for this class. ' +
9898 'Ask Container for it, using Container.get' ) ;
9999 }
0 commit comments