import "reflect-metadata";

export class InstanceContainer {
	private container: Map<string, any>;

	constructor() {
		this.container = new Map<string, any>();
	}

	get<T>(instanceIdentifier: string): T {
		const instance = this.container.get(instanceIdentifier);
		if (!instance) {
			throw new Error("Could not find instance (" + instanceIdentifier + ") in the container! Did you provide it in the module?");
		}
		return instance;
	}

	add<T>(instanceIdentifier: string, instance: T): void {
		this.container.set(instanceIdentifier, instance);
	}
}
