Skip to main content
Module

x/mandarinets/main-core/proxys/dependencyInjectionDecorator.ts

Mandarine.TS is a typescript, decorator-driven framework that allows you to create server-side applications. Mandarine.TS provides a range of built-in solutions such as Dependency Injection, Components, ORM and more. Under its umbrella, Mandarine.TS has 4 modules: Core, Data, Security and MVC, these modules will offer you the requirements to build a Mandarine-powered application.
Latest
File
// Copyright 2020-2020 The Mandarine.TS Framework authors. All rights reserved. MIT license.
import { ApplicationContext } from "../application-context/mandarineApplicationContext.ts";import { DI } from "../dependency-injection/di.ns.ts";import { DependencyInjectionUtil } from "../dependency-injection/di.util.ts";import { Mandarine } from "../Mandarine.ns.ts";
/** * Logic behind decorators of Dependency Injection's core */export class DependencyInjectionDecoratorsProxy {
public static registerInject(targetClass: any, propertyName: string, propertyInMethodIndex: number) { DependencyInjectionUtil.defineInjectionMetadata(DI.InjectionTypes.INJECTABLE_OBJECT, targetClass, propertyName, propertyInMethodIndex); }
public static registerInjectableDecorator(targetClass: any, methodName: string) { let componentExist: boolean = ApplicationContext.getInstance().getComponentsRegistry().exist(methodName);
if(!componentExist) { ApplicationContext.getInstance().getComponentsRegistry().register(methodName, targetClass[methodName](), Mandarine.MandarineCore.ComponentTypes.MANUAL_COMPONENT, {}); } }
}