有没有办法我可以实例化一个 Javascript 变量(使用 ClearScript.V8)并在 C# 中捕获更新,以便我可以更新数据库中的值?
它在我使用对象时起作用,如下所示:
public class SmartBoolean : ISmartVariable
{
private Boolean _simulation;
private Guid UserId;
private long userKeyId;
private long variableKeyId;
private string Name;
private Boolean _value;
public Boolean value
{
get {
return _value;
}
set {
_value = value;
if (!_simulation)
{
if (value)
new SmartCommon().SetTrue(userKeyId, variableKeyId);
else
new SmartCommon().SetFalse(userKeyId, variableKeyId);
}
}
}
public SmartBoolean(Guid UserId, long userKeyId, long variableKeyId, string Name, Boolean value, Boolean simulation)
{
this.Name = Name;
this._value = value;
this.UserId = UserId;
this.userKeyId = userKeyId;
this.variableKeyId = variableKeyId;
this._simulation = simulation;
}
public Boolean toggle()
{
this.value = !this._value;
return this._value;
}
}
但随后 Javascript 代码需要使用类似的对象
变量.值
而不是简单地
多变的
.