import { MetaKey } from '../consts' ; const metaKey = MetaKey . inject ; export interface InjectMeta { index : number ; key : string ; } export type InjectMetaList = InjectMeta [ ] ; export function getInjectMetaList ( controller ) { const metaList = Reflect . getMetadata ( metaKey , controller ) ; if ( metaList == null ) return [ ] ; return metaList ; } export function setInjectMetaList ( controller , meta ) { Reflect . defineMetadata ( metaKey , meta , controller ) ; } export function inject ( key ) { return function controllerDecorator ( target , propertyKey , index ) { const previousInjectMetaList = getInjectMetaList ( target ) ; const meta = [ { index , key } , ... previousInjectMetaList ] ; setInjectMetaList ( target , meta ) ; } ; }