Gibt es eine Möglichkeit, eine JavaScript-Variable (mit ClearScript.V8) instanziieren und die Updates in C# abfangen, so dass ich den Wert in der Datenbank aktualisieren kann?Wie erhalte ich ein Update-Ereignis in ClearScript.V8?
Es funktioniert, wenn ich ein Objekt verwenden, wie folgt aus:
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;
}
}
aber dann muss der Javascript-Code ein Objekt wie
variable.value
stattdessen verwenden von einfach
variabel
.