mercredi 1 février 2017

Get field definitions from TypeScript class with reflection

I am trying to port a C# application to TypeScript. The InPort and OutPort classes are part of a framework and are used in the following class:

@TaskPlugin
export class MyPlugin {

    public inp = new InPort<TestMessage>(this.processMessage);
    public out = new OutPort<TestMessage>();

    private processMessage(message:TestMessage):void{
         console.log(message);
    }
}

The framework can detect the plugin through the TaskPlugin decorator, but how can it discover the inp and out fields?

I need to discover these fields in order to create routing between different plugins. I could (?) add a decorator to the fields, but that is silly as they do not add any functionality.

Any ideas?





Aucun commentaire:

Enregistrer un commentaire