import { Container } from 'inversify' ; import { Abstract , IServiceContainer , IServiceManager , Newable } from '../src/ioc/types' ; export class TestServiceContainer implements IServiceContainer , IServiceManager { private cont : Container ; constructor ( ) { this . cont = new Container ( ) ; } public add < T > ( serviceIdentifier , constructor , name ? ) { if ( name ) { this . cont . bind < T > ( serviceIdentifier ) . to ( constructor ) . whenTargetNamed ( name ) ; } else { this . cont . bind < T > ( serviceIdentifier ) . to ( constructor ) ; } } public addSingleton < T > ( serviceIdentifier , constructor , name ? ) { if ( name ) { this . cont . bind < T > ( serviceIdentifier ) . to ( constructor ) . whenTargetNamed ( name ) ; } else { this . cont . bind < T > ( serviceIdentifier ) . to ( constructor ) ; } } public addSingletonInstance < T > ( serviceIdentifier , instance , name ? ) { if ( name ) { this . cont . bind < T > ( serviceIdentifier ) . toConstantValue ( instance ) . whenTargetNamed ( name ) ; } else { this . cont . bind < T > ( serviceIdentifier ) . toConstantValue ( instance ) ; } } public get < T > ( serviceIdentifier , name ? ) { return name ? this . cont . getNamed < T > ( serviceIdentifier , name ) : this . cont . get < T > ( serviceIdentifier ) ; } public getAll < T > ( serviceIdentifier , name ? ) { return name ? this . cont . getAllNamed < T > ( serviceIdentifier , name ) : this . cont . getAll < T > ( serviceIdentifier ) ; } }