How to use the inversify.decorate 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 ParallelTask / dinoloop / examples / inversify_basic / src / app / container / container.ts View on Github external
// builtin abstract classes which are to be extended, must go through decorate()
// else inversify wont work because inversify expects the inherited members to have @injectable()
decorate(injectable(), ApiController);
decorate(injectable(), ErrorController);
decorate(injectable(), RequestStartMiddleware);
decorate(injectable(), RequestStartMiddlewareAsync);
decorate(injectable(), RequestEndMiddleware);
decorate(injectable(), RequestEndMiddlewareAsync);
decorate(injectable(), Middleware);
decorate(injectable(), MiddlewareAsync);
decorate(injectable(), ActionFilter);
decorate(injectable(), ActionFilterAsync);
decorate(injectable(), ErrorMiddleware);
decorate(injectable(), ErrorMiddlewareAsync);
decorate(injectable(), ResultFilter);
decorate(injectable(), ResultFilterAsync);
decorate(injectable(), ExceptionFilter);
decorate(injectable(), ExceptionFilterAsync);
decorate(injectable(), IUserIdentity);
decorate(injectable(), UserIdentity);

let container = new Container();
container.bind(IAboutService).to(AboutService);
container.bind(HomeController).toSelf();
container.bind(ApplicationError).toSelf();
container.bind(StartMiddleware).toSelf();
container.bind(ResponseMiddleware).toSelf();

export { container as InversifyContainer };
github vscode-icons / vscode-icons / src / services / compositionRootService.ts View on Github external
this.injectableClasses.forEach(injectableClass => {
      // declare classes as injectables
      const klass: Class = injectableClass[0];
      decorate(injectable(), klass);
      // declare injectable parameters
      const params: ServiceIdentifierOrFunc[] = injectableClass[1];
      params.forEach((identifier: ServiceIdentifierOrFunc, index: number) =>
        decorate(inject(identifier), klass, index),
      );
    });
  }
github ParallelTask / dinoloop / examples / inversify_basic / src / app / container / container.ts View on Github external
ExceptionFilter,
    ExceptionFilterAsync,
    IUserIdentity,
    UserIdentity
} from '../../../../index';
import { HomeController } from '../controllers/home.controller';
import { ApplicationError } from '../controllers/application.error';
import { IAboutService, AboutService } from '../services/about.service';
import { StartMiddleware, ResponseMiddleware } from '../services/middleware';

// builtin abstract classes which are to be extended, must go through decorate()
// else inversify wont work because inversify expects the inherited members to have @injectable()
decorate(injectable(), ApiController);
decorate(injectable(), ErrorController);
decorate(injectable(), RequestStartMiddleware);
decorate(injectable(), RequestStartMiddlewareAsync);
decorate(injectable(), RequestEndMiddleware);
decorate(injectable(), RequestEndMiddlewareAsync);
decorate(injectable(), Middleware);
decorate(injectable(), MiddlewareAsync);
decorate(injectable(), ActionFilter);
decorate(injectable(), ActionFilterAsync);
decorate(injectable(), ErrorMiddleware);
decorate(injectable(), ErrorMiddlewareAsync);
decorate(injectable(), ResultFilter);
decorate(injectable(), ResultFilterAsync);
decorate(injectable(), ExceptionFilter);
decorate(injectable(), ExceptionFilterAsync);
decorate(injectable(), IUserIdentity);
decorate(injectable(), UserIdentity);

let container = new Container();
github project-flogo / flogo-web / apps / server / src / injector / plugin-injection / resource-registrar.spec.ts View on Github external
test('it should not try to re-decorate as injectable already decorated plugins', () => {
  decorate(injectable(), resourceHooks);
  expect(() =>
    registerResourcePlugin({
      resourceType: 'resourceType',
      resourceHooks: resourceHooks,
    })
  ).not.toThrow();
});
github ParallelTask / dinoloop / examples / inversify_basic / src / app / container / container.ts View on Github external
decorate(injectable(), ErrorController);
decorate(injectable(), RequestStartMiddleware);
decorate(injectable(), RequestStartMiddlewareAsync);
decorate(injectable(), RequestEndMiddleware);
decorate(injectable(), RequestEndMiddlewareAsync);
decorate(injectable(), Middleware);
decorate(injectable(), MiddlewareAsync);
decorate(injectable(), ActionFilter);
decorate(injectable(), ActionFilterAsync);
decorate(injectable(), ErrorMiddleware);
decorate(injectable(), ErrorMiddlewareAsync);
decorate(injectable(), ResultFilter);
decorate(injectable(), ResultFilterAsync);
decorate(injectable(), ExceptionFilter);
decorate(injectable(), ExceptionFilterAsync);
decorate(injectable(), IUserIdentity);
decorate(injectable(), UserIdentity);

let container = new Container();
container.bind(IAboutService).to(AboutService);
container.bind(HomeController).toSelf();
container.bind(ApplicationError).toSelf();
container.bind(StartMiddleware).toSelf();
container.bind(ResponseMiddleware).toSelf();

export { container as InversifyContainer };
github eclipse-theia / theia / packages / monaco / src / browser / monaco-languages.ts View on Github external
MonacoLanguages as BaseMonacoLanguages, ProtocolToMonacoConverter,
    MonacoToProtocolConverter,
    DocumentSelector,
    SignatureHelpProvider,
    MonacoModelIdentifier,
    CodeActionProvider,
    CodeLensProvider
} from 'monaco-languageclient';
import { Languages, Diagnostic, DiagnosticCollection, Language, WorkspaceSymbolProvider } from '@theia/languages/lib/browser';
import { ProblemManager } from '@theia/markers/lib/browser/problem/problem-manager';
import URI from '@theia/core/lib/common/uri';
import { Mutable } from '@theia/core/lib/common/types';
import { Disposable } from '@theia/core/lib/common/disposable';
import { MonacoDiagnosticCollection } from 'monaco-languageclient/lib/monaco-diagnostic-collection';

decorate(injectable(), BaseMonacoLanguages);
decorate(inject(ProtocolToMonacoConverter), BaseMonacoLanguages, 0);
decorate(inject(MonacoToProtocolConverter), BaseMonacoLanguages, 1);

@injectable()
export class MonacoLanguages extends BaseMonacoLanguages implements Languages {

    readonly workspaceSymbolProviders: WorkspaceSymbolProvider[] = [];

    protected readonly makers = new Map();

    constructor(
        @inject(ProtocolToMonacoConverter) p2m: ProtocolToMonacoConverter,
        @inject(MonacoToProtocolConverter) m2p: MonacoToProtocolConverter,
        @inject(ProblemManager) protected readonly problemManager: ProblemManager
    ) {
        super(p2m, m2p);
github eclipse-theia / theia / packages / monaco / src / browser / monaco-editor-service.ts View on Github external
*
 * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
 ********************************************************************************/

import { injectable, inject, decorate } from 'inversify';
import { MonacoToProtocolConverter } from 'monaco-languageclient';
import URI from '@theia/core/lib/common/uri';
import { OpenerService, open, WidgetOpenMode, ApplicationShell, PreferenceService } from '@theia/core/lib/browser';
import { EditorWidget, EditorOpenerOptions, EditorManager } from '@theia/editor/lib/browser';
import { MonacoEditor } from './monaco-editor';

import ICodeEditor = monaco.editor.ICodeEditor;
import CommonCodeEditor = monaco.editor.CommonCodeEditor;
import IResourceInput = monaco.editor.IResourceInput;

decorate(injectable(), monaco.services.CodeEditorServiceImpl);

@injectable()
export class MonacoEditorService extends monaco.services.CodeEditorServiceImpl {

    public static readonly ENABLE_PREVIEW_PREFERENCE: string = 'editor.enablePreview';

    @inject(OpenerService)
    protected readonly openerService: OpenerService;

    @inject(MonacoToProtocolConverter)
    protected readonly m2p: MonacoToProtocolConverter;

    @inject(ApplicationShell)
    protected readonly shell: ApplicationShell;

    @inject(EditorManager)
github RiseVision / rise-node / packages / core-consensus-dpos / src / hooks / subscribers / roundsHooks.ts View on Github external
} from '@risevision/core-types';
import { catchToLoggerAndRemapError } from '@risevision/core-utils';
import * as fs from 'fs';
import { decorate, inject, injectable, named } from 'inversify';
import { WordPressHookSystem, WPHooksSubscriber } from 'mangiafuoco';
import { DposConstantsType, dPoSSymbols } from '../../helpers';
import { RoundsLogic } from '../../logic/rounds';
import {
  Accounts2DelegatesModel,
  Accounts2U_DelegatesModel,
  VotesModel,
} from '../../models';
import { RoundsModule } from '../../modules';

const Extendable = WPHooksSubscriber(Object);
decorate(injectable(), Extendable);

@injectable()
export class RoundsHooks extends Extendable {
  @inject(Symbols.generic.hookSystem)
  public hookSystem: WordPressHookSystem;

  @inject(Symbols.helpers.logger)
  private logger: ILogger;
  @inject(dPoSSymbols.logic.rounds)
  private roundsLogic: RoundsLogic;

  @inject(dPoSSymbols.modules.rounds)
  private roundsModule: RoundsModule;
  @inject(ModelSymbols.model)
  @named(dPoSSymbols.models.votes)
  private VotesModel: typeof VotesModel;