/**
 * Factory for creating services.
 */ export class ServiceFactory { /**
     * Store the service callbacks.
     */ private static readonly _services : { [ name ] : ( ) => unknown ; } = { } ; /**
     * Store the created instances.
     */ private static readonly _instances : { [ name ] : unknown ; } = { } ; param name param instanceCallback public static register ( name , instanceCallback ) { this . _services [ name ] = instanceCallback ; if ( this . _instances [ name ] ) { delete this . _instances [ name ] ; } } param name public static unregister ( name ) { delete this . _services [ name ] ; if ( this . _instances [ name ] ) { delete this . _instances [ name ] ; } } param name returns public static get < T > ( name ) { if ( ! this . _instances [ name ] && this . _services [ name ] ) { this . _instances [ name ] = this . _services [ name ] ( ) ; } return this . _instances [ name ] as T ; } }