You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
729 B
30 lines
729 B
import {Factory} from './Factory'
|
|
import {Instantiable} from '../types'
|
|
|
|
/**
|
|
* Container factory that produces an instance of the token, however the token
|
|
* is identified by a string name rather than a class reference.
|
|
* @extends Factory
|
|
*/
|
|
export default class NamedFactory<T> extends Factory<T> {
|
|
constructor(
|
|
/**
|
|
* The name identifying this factory in the container.
|
|
* @type {string}
|
|
*/
|
|
protected name: string,
|
|
|
|
/**
|
|
* The token to be instantiated.
|
|
* @type {Instantiable}
|
|
*/
|
|
protected token: Instantiable<T>,
|
|
) {
|
|
super(token)
|
|
}
|
|
|
|
match(something: unknown): boolean {
|
|
return something === this.name
|
|
}
|
|
}
|