我在脚本#0.7.5中有以下类:
[ScriptNamespace("Scripts")]
public class MyClass
{
private Dictionary<string, string> stageMapping = new Dictionary<string, string>();
public PortfolioOptimisationOverlord()
{
stageMapping["first"] = "http://www.me.com/mike";
stageMapping["second"] = "http://www.me.com/terry";
stageMapping["third"] = "http://www.me.com/billy";
stageMapping["fourth"] = "http://www.me.com/bobby";
stageMapping["fifth"] = "http://www.me.com/richard";
}
}
遗憾的是,在编译时它不会生成原型类,因此无法说它无法访问this
。
如果我创建一个int
类型的私有字段,它似乎可以工作,但不能用于字典或列表。
- EDIT--
这里有更多信息:
由此产生的JavaScript是:
////////////////////////////////////////////////////////////////////////////////
// Scripts.PortfolioOptimisationOverlord
Scripts.PortfolioOptimisationOverlord = function Scripts_PortfolioOptimisationOverlord() {
/// <field name="_stageMapping" type="Object">
/// </field>
this._stageMapping = {};
this._stageMapping['first'] = 'http://www.me.com/mike';
this._stageMapping['second'] = 'http://www.me.com/terry';
this._stageMapping['third'] = 'http://www.me.com/billy';
this._stageMapping['fourth'] = 'http://www.me.com/bobby';
this._stageMapping['fifth'] = 'http://www.me.com/richard';
}
如果我添加名为int
的{{1}}私有字段:
intField
正如您所看到的,唯一的变化是在最后添加了一个带有 ////////////////////////////////////////////////////////////////////////////////
// Scripts.PortfolioOptimisationOverlord
Scripts.PortfolioOptimisationOverlord = function Scripts_PortfolioOptimisationOverlord() {
/// <field name="_stageMapping" type="Object">
/// </field>
/// <field name="_intField" type="Number" integer="true">
/// </field>
this._stageMapping = {};
this._stageMapping['first'] = 'http://www.me.com/mike';
this._stageMapping['second'] = 'http://www.me.com/terry';
this._stageMapping['third'] = 'http://www.me.com/billy';
this._stageMapping['fourth'] = 'http://www.me.com/bobby';
this._stageMapping['fifth'] = 'http://www.me.com/richard';
}
Scripts.PortfolioOptimisationOverlord.prototype = {
_intField: 0
}
的类型。
它在施工时失败了。
答案 0 :(得分:0)
似乎0.8就是答案。感谢所有提供帮助的人。