lam*_*ama 5 c# typescript asp.net-core nswag angular
我正在使用 NSwag.CodeGeneration.Typescript 从 .net-core 后端和 swagger.json 生成一个 angular 2 typescript 代理。这就像一个魅力。
现在我希望能够为我的打字稿客户端自动生成自定义装饰器。像这样的东西:
C# 类:
public class Point {
// a configurable annotation here
[configurable]
private int X
{
get; set;
}
// a configurable annotation here
[configurable]
private int Y
{
get; set;
}
}
Run Code Online (Sandbox Code Playgroud)
生成的打字稿代理...
class Point {
private _x: number;
private _y: number;
constructor(data?: any) {
// set data
}
@configurable(false)
get x() { return this._x; }
@configurable(false)
get y() { return this._y; }
}
Run Code Online (Sandbox Code Playgroud)
...使用自定义装饰器功能
function configurable(value: boolean) {
return function (target: any, propertyKey: string, descriptor: PropertyDescriptor) {
descriptor.configurable = value;
};
}
Run Code Online (Sandbox Code Playgroud)
这是我第一个大摇大摆的项目,所以我不完全确定从哪里开始。任何帮助是极大的赞赏。
| 归档时间: |
|
| 查看次数: |
596 次 |
| 最近记录: |