RenaiApp/src/main/core/container.ts

36 lines
1.1 KiB
TypeScript

import 'reflect-metadata';
import { Container, interfaces } from 'inversify';
import { MainAppWindow } from '../modules/app-window/main-app-window';
import { Logger } from '../modules/logger/logger';
import { NhentaiApi } from '../modules/nhentai/nhentai-api';
import '../modules/nhentai/nhentai-ipc-controller';
import { Session } from '../modules/session/session';
import { Store } from '../modules/store/store';
import { WebCrawler } from '../modules/web-crawler/web-crawler';
import BindingToSyntax = interfaces.BindingToSyntax;
export const container = {
original: new Container({ defaultScope: 'Singleton' }),
bind<T>(key: string): BindingToSyntax<T> {
return this.original.bind<T>(Symbol.for(key));
},
unbind(key: string): void {
return this.original.unbind(Symbol.for(key));
},
get<T>(key: string): T {
return this.original.get<T>(Symbol.for(key));
},
};
container.bind('logger').to(Logger);
container.bind('store').to(Store);
container.bind('web-crawler').to(WebCrawler);
container.bind('nhentai-api').to(NhentaiApi);
container.bind('app-window-main').to(MainAppWindow);
container.bind('session').to(Session);