我想将我用 C# 编写的类公开给 javascript 等价物。
例如我有一个像这样的类:
// C# class to represent an Appriaser
public class Appraiser
{
public Appraiser(appraiserId, appraiserName)
{
AppraiserId = appraiserId;
AppraiserName = appraiserName;
}
public int AppraiserId { get; set; }
public string AppraiserName { get; set; }
}
我希望能够在 javascript 中自动生成此类的一个版本
// javascript class to represent an Appraiser
function Appraiser(appraiserId, appraiserName) {
var self = this;
self.appraiserid= appraiserId;
self.appraisername= appraisername;
}
JSON.NET 或其他方法可以做到这一点吗?