45 lines
1.4 KiB
TypeScript
45 lines
1.4 KiB
TypeScript
|
import {DependencyRequirement, PropertyDependency} from "../types";
|
||
|
import { Collection } from "../../util";
|
||
|
|
||
|
/**
|
||
|
* Abstract base class for dependency container factories.
|
||
|
* @abstract
|
||
|
*/
|
||
|
export abstract class AbstractFactory {
|
||
|
protected constructor(
|
||
|
/**
|
||
|
* Token that was registered for this factory. In most cases, this is the static
|
||
|
* form of the item that is to be produced by this factory.
|
||
|
* @var
|
||
|
* @protected
|
||
|
*/
|
||
|
protected token: any
|
||
|
) {}
|
||
|
|
||
|
/**
|
||
|
* Produce an instance of the token.
|
||
|
* @param {Array} dependencies - the resolved dependencies, in order
|
||
|
* @param {Array} parameters - the bound constructor parameters, in order
|
||
|
*/
|
||
|
abstract produce(dependencies: any[], parameters: any[]): any
|
||
|
|
||
|
/**
|
||
|
* Should return true if the given identifier matches the token for this factory.
|
||
|
* @param something
|
||
|
* @return boolean
|
||
|
*/
|
||
|
abstract match(something: any): boolean
|
||
|
|
||
|
/**
|
||
|
* Get the dependency requirements required by this factory's token.
|
||
|
* @return Collection<DependencyRequirement>
|
||
|
*/
|
||
|
abstract getDependencyKeys(): Collection<DependencyRequirement>
|
||
|
|
||
|
/**
|
||
|
* Get the property dependencies that should be injected to the created instance.
|
||
|
* @return Collection<PropertyDependency>
|
||
|
*/
|
||
|
abstract getInjectedProperties(): Collection<PropertyDependency>
|
||
|
}
|