ts-ioc-container
Version:
Fast, lightweight TypeScript dependency injection container with a clean API, scoped lifecycles, decorators, tokens, hooks, lazy injection, customizable providers, and no global container objects.
68 lines (67 loc) • 1.84 kB
JavaScript
import { MethodNotImplementedError } from '../errors/MethodNotImplementedError';
import { DependencyNotFoundError } from '../errors/DependencyNotFoundError';
import { ContainerNotFoundError } from '../errors/ContainerNotFoundError';
export class EmptyContainer {
get isDisposed() {
throw new MethodNotImplementedError();
}
addInstance(instance) { }
getParent() {
return undefined;
}
getScopes() {
return [];
}
getScopeByInstanceOrFail(instance) {
throw new ContainerNotFoundError('Cannot find scope for the given instance');
}
getInstances() {
return [];
}
hasInstance(instance) {
return false;
}
createScope() {
throw new MethodNotImplementedError();
}
dispose() {
throw new MethodNotImplementedError();
}
register(key, value) {
throw new MethodNotImplementedError();
}
hasTag(tag) {
throw new MethodNotImplementedError();
}
addTags(...tags) {
throw new MethodNotImplementedError();
}
getRegistrations() {
return [];
}
hasRegistration(key) {
return false;
}
removeScope() { }
useModule(module) {
throw new MethodNotImplementedError();
}
addRegistration(registration) {
throw new MethodNotImplementedError();
}
resolve(key, options) {
throw new DependencyNotFoundError(`Cannot find ${key.toString()}`);
}
resolveByAlias(alias, options) {
return [];
}
resolveOneByAlias(alias, options) {
throw new DependencyNotFoundError(`Cannot find alias ${alias.toString()}`);
}
addOnDisposeHook(...hooks) {
throw new MethodNotImplementedError();
}
addOnConstructHook(...hooks) {
throw new MethodNotImplementedError();
}
}