本文整理汇总了C#中Jint.Engine.ResetStatementsCount方法的典型用法代码示例。如果您正苦于以下问题:C# Engine.ResetStatementsCount方法的具体用法?C# Engine.ResetStatementsCount怎么用?C# Engine.ResetStatementsCount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Jint.Engine
的用法示例。
在下文中一共展示了Engine.ResetStatementsCount方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PrepareEngine
private void PrepareEngine(ScriptedPatchRequest patch, string docId, int size, ScriptedJsonPatcherOperationScope scope, Engine jintEngine)
{
jintEngine.Global.Delete("PutDocument", false);
jintEngine.Global.Delete("LoadDocument", false);
jintEngine.Global.Delete("DeleteDocument", false);
CustomizeEngine(jintEngine, scope);
jintEngine.SetValue("PutDocument", (Action<string, object, object>)((key, document, metadata) => scope.PutDocument(key, document, metadata, jintEngine)));
jintEngine.SetValue("LoadDocument", (Func<string, JsValue>)(key => scope.LoadDocument(key, jintEngine)));
jintEngine.SetValue("DeleteDocument", (Action<string>)(scope.DeleteDocument));
jintEngine.SetValue("__document_id", docId);
foreach (var kvp in patch.Values)
{
var token = kvp.Value as RavenJToken;
if (token != null)
{
jintEngine.SetValue(kvp.Key, scope.ToJsInstance(jintEngine, token));
}
else
{
var rjt = RavenJToken.FromObject(kvp.Value);
var jsInstance = scope.ToJsInstance(jintEngine, rjt);
jintEngine.SetValue(kvp.Key, jsInstance);
}
}
jintEngine.ResetStatementsCount();
if (size != 0)
jintEngine.Options.MaxStatements(maxSteps + (size * additionalStepsPerSize));
}
示例2: PrepareEngine
private void PrepareEngine(ScriptedPatchRequest patch, string docId, int size, ScriptedJsonPatcherOperationScope scope, Engine jintEngine)
{
scope.AdditionalStepsPerSize = additionalStepsPerSize;
scope.MaxSteps = maxSteps;
if (size != 0)
{
totalScriptSteps = maxSteps + (size * additionalStepsPerSize);
jintEngine.Options.MaxStatements(TotalScriptSteps);
}
jintEngine.Global.Delete("PutDocument", false);
jintEngine.Global.Delete("LoadDocument", false);
jintEngine.Global.Delete("DeleteDocument", false);
jintEngine.Global.Delete("IncreaseNumberOfAllowedStepsBy", false);
CustomizeEngine(jintEngine, scope);
jintEngine.SetValue("PutDocument", (Func<string, object, object, string>)((key, document, metadata) => scope.PutDocument(key, document, metadata, jintEngine)));
jintEngine.SetValue("LoadDocument", (Func<string, JsValue>)(key => scope.LoadDocument(key, jintEngine, ref totalScriptSteps)));
jintEngine.SetValue("DeleteDocument", (Action<string>)(scope.DeleteDocument));
jintEngine.SetValue("__document_id", docId);
jintEngine.SetValue("IncreaseNumberOfAllowedStepsBy", (Action<int>)(number =>
{
if (database != null && database.Configuration.AllowScriptsToAdjustNumberOfSteps)
{
scope.MaxSteps += number;
jintEngine.Options.MaxStatements(totalScriptSteps + number);
return;
}
throw new InvalidOperationException("Cannot use 'IncreaseNumberOfAllowedStepsBy' method, because `Raven/AllowScriptsToAdjustNumberOfSteps` is set to false.");
}));
foreach (var kvp in patch.Values)
{
var token = kvp.Value as RavenJToken;
if (token != null)
{
jintEngine.SetValue(kvp.Key, scope.ToJsInstance(jintEngine, token));
}
else
{
var rjt = RavenJToken.FromObject(kvp.Value);
var jsInstance = scope.ToJsInstance(jintEngine, rjt);
jintEngine.SetValue(kvp.Key, jsInstance);
}
}
jintEngine.ResetStatementsCount();
}