How to use the inversify.ContainerModule function in inversify

To help you get started, we’ve selected a few inversify examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github JohnSimerlink / branches_front_end_private / inversify.config.ts View on Github external
bind(TYPES.MutableSubscribableGlobalStoreArgs)
		.to(MutableSubscribableGlobalStoreArgs);

	bind
	(TYPES.IMutableSubscribableGlobalStore)
		.to(MutableSubscribableGlobalStore)
		.inSingletonScope()
		.whenTargetIsDefault();



		// ^^ This will get overriden in the BranchesStore constructor
});
//
const rendering = new ContainerModule((bind: interfaces.Bind, unbind: interfaces.Unbind) => {
	bind(TYPES.radian).toConstantValue(0);
	bind(TYPES.fGetStore).toConstantValue(() => { return { commit(){}} as any as Store})

	const {
		CanvasUI,
		CanvasUIArgs
	} = require('./app/objects/sigmaNode/CanvasUI');
	bind(TYPES.CanvasUI).to(CanvasUI);
	bind(TYPES.CanvasUIArgs)
		.to(CanvasUIArgs);

	// TODO: fix these bindings for if we have multiple sigma instances.
	bind(TYPES.ISigmaNodes).toConstantValue({});
	bind(TYPES.ISigmaEdges).toConstantValue({});

	bind(TYPES.IContentUserData).toDynamicValue((context: interfaces.Context) => {
github javascript-obfuscator / javascript-obfuscator / src / container / modules / node-transformers / ConvertingTransformersModule.ts View on Github external
import { INodeTransformer } from '../../../interfaces/node-transformers/INodeTransformer';
import { IPropertiesExtractor } from '../../../interfaces/node-transformers/converting-transformers/properties-extractors/IPropertiesExtractor';

import { NodeTransformer } from '../../../enums/node-transformers/NodeTransformer';
import { PropertiesExtractor } from '../../../enums/node-transformers/converting-transformers/properties-extractors/PropertiesExtractor';

import { AssignmentExpressionPropertiesExtractor } from '../../../node-transformers/converting-transformers/properties-extractors/AssignmentExpressionPropertiesExtractor';
import { MemberExpressionTransformer } from '../../../node-transformers/converting-transformers/MemberExpressionTransformer';
import { MethodDefinitionTransformer } from '../../../node-transformers/converting-transformers/MethodDefinitionTransformer';
import { ObjectExpressionKeysTransformer } from '../../../node-transformers/converting-transformers/ObjectExpressionKeysTransformer';
import { ObjectExpressionTransformer } from '../../../node-transformers/converting-transformers/ObjectExpressionTransformer';
import { SplitStringTransformer } from '../../../node-transformers/converting-transformers/SplitStringTransformer';
import { TemplateLiteralTransformer } from '../../../node-transformers/converting-transformers/TemplateLiteralTransformer';
import { VariableDeclaratorPropertiesExtractor } from '../../../node-transformers/converting-transformers/properties-extractors/VariableDeclaratorPropertiesExtractor';

export const convertingTransformersModule: interfaces.ContainerModule = new ContainerModule((bind: interfaces.Bind) => {
    // converting transformers
    bind(ServiceIdentifiers.INodeTransformer)
        .to(MemberExpressionTransformer)
        .whenTargetNamed(NodeTransformer.MemberExpressionTransformer);

    bind(ServiceIdentifiers.INodeTransformer)
        .to(MethodDefinitionTransformer)
        .whenTargetNamed(NodeTransformer.MethodDefinitionTransformer);

    bind(ServiceIdentifiers.INodeTransformer)
        .to(ObjectExpressionKeysTransformer)
        .whenTargetNamed(NodeTransformer.ObjectExpressionKeysTransformer);

    bind(ServiceIdentifiers.INodeTransformer)
        .to(ObjectExpressionTransformer)
        .whenTargetNamed(NodeTransformer.ObjectExpressionTransformer);
github spring-projects / sts4 / nodejs-packages / sprotty-live-beans-client / src / di.config.ts View on Github external
export default (transport: TransportMedium, clientId: string) => {
    require("sprotty/css/sprotty.css");
    require("../css/diagram.css");
    const circlegraphModule = new ContainerModule((bind, unbind, isBound, rebind) => {
        switch (transport) {
            case TransportMedium.Websocket:
                bind(TYPES.ModelSource).to(ExampleWebsocketDiagramServer).inSingletonScope();
                break;
            case TransportMedium.LSP:
                bind(TYPES.ModelSource).to(VSCodeWebViewDiagramServer).inSingletonScope();
                break;
            default:
                bind(TYPES.ModelSource).to(LocalModelSource).inSingletonScope();
        }
        rebind(TYPES.ILogger).to(ConsoleLogger).inSingletonScope();
        rebind(TYPES.LogLevel).toConstantValue(LogLevel.log);
        const context = { bind, unbind, isBound, rebind };
        configureModelElement(context, 'graph', SGraph, ExampleGraphView);
        configureModelElement(context, 'node:circle', CircularNode, CircleNodeView);
        configureModelElement(context, 'node:bean', BeanNode, BeanNodeView);
github eclipsesource / graphical-lsp / client / packages / sprotty-client / src / features / save / di.config.ts View on Github external
* http://www.eclipse.org/legal/epl-2.0.
 *
 * This Source Code may also be made available under the following Secondary
 * Licenses when the conditions for such availability set forth in the Eclipse
 * Public License v. 2.0 are satisfied: GNU General Public License, version 2
 * with the GNU Classpath Exception which is available at
 * https://www.gnu.org/software/classpath/license.html.
 *
 * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
 ********************************************************************************/
import { ContainerModule } from "inversify";
import { TYPES } from "sprotty/lib/base/types";

import { SaveModelKeyboardListener } from "./save";

const saveModule = new ContainerModule(bind => {
    bind(TYPES.KeyListener).to(SaveModelKeyboardListener);

});

export default saveModule;
github stelltec / public-tech-demos / nodejs-madrid-meetup / demo3 / src / infrastructure / ioc / modules.ts View on Github external
import { ContainerModule } from "inversify";
import { MovieController } from "../../ui/rest_api/movie_controller";
import { DirectorController } from "../../ui/rest_api/director_controller";
import { ActorController } from "../../ui/rest_api/actor_controller";
import { MovieRepository } from "../data_access/repositories/movie_repository";
import { DirectorRepository } from "../data_access/repositories/director_repository";
import { ActorRepository } from "../data_access/repositories/actor_repository";
import { registerController } from "./utils";
import { TYPES } from "../../domain/constants/types";

export const referenceDataIoCModule = new ContainerModule((bind) => {
    registerController(bind, MovieController);
    registerController(bind, DirectorController);
    registerController(bind, ActorController);
    bind(TYPES.MovieRepository).to(MovieRepository).inSingletonScope();
    bind(TYPES.DirectorRepository).to(DirectorRepository).inSingletonScope();
    bind(TYPES.ActorRepository).to(ActorRepository).inSingletonScope();
});
github eclipse / sprotty / src / features / export / di.config.ts View on Github external
* This Source Code may also be made available under the following Secondary
 * Licenses when the conditions for such availability set forth in the Eclipse
 * Public License v. 2.0 are satisfied: GNU General Public License, version 2
 * with the GNU Classpath Exception which is available at
 * https://www.gnu.org/software/classpath/license.html.
 *
 * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
 ********************************************************************************/

import { ContainerModule } from "inversify";
import { TYPES } from '../../base/types';
import { ExportSvgPostprocessor, ExportSvgKeyListener, ExportSvgCommand } from './export';
import { SvgExporter } from './svg-exporter';
import { configureCommand } from "../../base/commands/command-registration";

const exportSvgModule = new ContainerModule((bind, _unbind, isBound) => {
    bind(TYPES.KeyListener).to(ExportSvgKeyListener).inSingletonScope();
    bind(TYPES.HiddenVNodePostprocessor).to(ExportSvgPostprocessor).inSingletonScope();
    configureCommand({ bind, isBound }, ExportSvgCommand);
    bind(TYPES.SvgExporter).to(SvgExporter).inSingletonScope();
});

export default exportSvgModule;
github theia-ide / sprotty / client / examples / mindmap / src / di.config.ts View on Github external
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
 */

import { Container, ContainerModule } from "inversify";
import {
    defaultModule, TYPES, ViewRegistry, overrideViewerOptions, SGraphView, SLabelView,
    ConsoleLogger, LogLevel, WebSocketDiagramServer, boundsModule, moveModule, selectModule,
    undoRedoModule, viewportModule, hoverModule, LocalModelSource, HtmlRootView, PreRenderedView,
    exportModule, expandModule, fadeModule, buttonModule, ActionHandlerRegistry, SGraphFactory,
    SModelElementRegistration, PreRenderedElement
} from "../../../src";
import { MindmapNodeView, PopupButtonView } from "./views";
import { popupModelFactory, PopupButtonMouseListener, AddElementCommand } from "./popup";
import { Mindmap, PopupButton } from "./model";

const mindmapModule = new ContainerModule((bind, unbind, isBound, rebind) => {
    rebind(TYPES.ILogger).to(ConsoleLogger).inSingletonScope();
    rebind(TYPES.LogLevel).toConstantValue(LogLevel.log);
    rebind(TYPES.IModelFactory).to(SGraphFactory).inSingletonScope();
    bind(TYPES.PopupModelFactory).toConstantValue(popupModelFactory);
    bind(TYPES.PopupMouseListener).to(PopupButtonMouseListener);
    bind(TYPES.SModelElementRegistration).toConstantValue({
        type: 'mindmap',
        constr: Mindmap
    });
    bind(TYPES.SModelElementRegistration).toConstantValue({
        type: 'popup:button',
        constr: PopupButton
    });
    bind(TYPES.SModelElementRegistration).toConstantValue({
        type: 'pre-rendered',
        constr: PreRenderedElement
github fimbullinter / wotan / packages / wotan / src / commands / save.ts View on Github external
);
        const filePath = path.join(this.directories.getCurrentDirectory(), '.fimbullinter.yaml');
        if (newContent.trim() === '{}') {
            try {
                this.fs.remove(filePath);
                this.logger.log("Removed '.fimbullinter.yaml'.");
            } catch {}
        } else {
            this.fs.writeFile(filePath, newContent);
            this.logger.log("Updated '.fimbullinter.yaml'.");
        }
        return true;
    }
}

export const module = new ContainerModule((bind) => {
    bind(AbstractCommandRunner).to(SaveCommandRunner);
});
github eclipsesource / graphical-lsp / client / packages / sprotty-client / src / features / select / di.config.ts View on Github external
* Public License v. 2.0 are satisfied: GNU General Public License, version 2
 * with the GNU Classpath Exception which is available at
 * https://www.gnu.org/software/classpath/license.html.
 *
 * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
 ********************************************************************************/
import { ContainerModule } from "inversify";
import { configureCommand, SelectKeyboardListener, TYPES } from "sprotty";

import { GLSP_TYPES } from "../../types";
import { SelectAllCommand, SelectAllFeedbackCommand, SelectCommand, SelectFeedbackCommand } from "./action-definitions";
import { RankedSelectMouseListener } from "./select-mouse-listener";
import { SelectionService } from "./selection-service";


const glspSelectModule = new ContainerModule((bind, _unbind, isBound) => {
    bind(SelectionService).toSelf().inSingletonScope();
    bind(GLSP_TYPES.SelectionService).toService(SelectionService);
    configureCommand({ bind, isBound }, SelectCommand);
    configureCommand({ bind, isBound }, SelectAllCommand);
    configureCommand({ bind, isBound }, SelectFeedbackCommand);
    configureCommand({ bind, isBound }, SelectAllFeedbackCommand);
    bind(TYPES.KeyListener).to(SelectKeyboardListener);
    bind(TYPES.MouseListener).to(RankedSelectMouseListener);
    bind(GLSP_TYPES.SModelRootListener).toService(SelectionService);
});

export default glspSelectModule;