本文整理汇总了C#中Jint.Engine.SetValue方法的典型用法代码示例。如果您正苦于以下问题:C# Engine.SetValue方法的具体用法?C# Engine.SetValue怎么用?C# Engine.SetValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Jint.Engine
的用法示例。
在下文中一共展示了Engine.SetValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ProcessMessage
public void ProcessMessage(object source, Message message)
{
string jsonScript = "var msg = " + JsonConvert.SerializeXmlNode(message.GetXmlDocument(), Formatting.Indented, true);
Engine engine = new Engine();
engine.SetValue("message", message);
engine.Execute(jsonScript);
engine.Execute(Script);
engine.Execute("var jsonMsg = JSON.stringify(msg);");
JsValue obj = engine.GetValue("jsonMsg");
string jsonString = obj.AsString();
var document = JsonConvert.DeserializeXNode(jsonString, "HL7Message");
message.SetValueFrom(document);
}
示例2: InstallProvider_WebUtils
internal void InstallProvider_WebUtils(Engine scriptScope)
{
InitializeScope_WebUtils(scriptScope);
scriptScope.SetValue("echo", new Func<object, int>(s => Echo(scriptScope, s)));
scriptScope.SetValue("header", new Func<string, int>(s => Header(scriptScope, s)));
scriptScope.SetValue("endheaders", new Action(() => EndHeaders(scriptScope)));
scriptScope.SetValue("die", new Action(() => Die(scriptScope)));
scriptScope.SetValue("error_reporting", new Func<int, int>(s => error_reporting(scriptScope, s)));
}
示例3: CustomizeEngine
protected override void CustomizeEngine(Engine jintEngine, ScriptedJsonPatcherOperationScope scope)
{
jintEngine.SetValue("documentId", docId);
jintEngine.SetValue("replicateTo", new Action<string,object>(ReplicateToFunction));
foreach (var sqlReplicationTable in config.SqlReplicationTables)
{
var current = sqlReplicationTable;
jintEngine.SetValue("replicateTo" + sqlReplicationTable.TableName, (Action<object>)(cols =>
{
var tableName = current.TableName;
ReplicateToFunction(tableName, cols);
}));
}
}
示例4: Initialize
public bool Initialize(UserGameInfo game, GameProfile profile)
{
this.userGame = game;
this.profile = profile;
// see if we have any save game to backup
gen = game.Game as GenericGameInfo;
if (gen == null)
{
// you fucked up
return false;
}
engine = new Engine();
engine.SetValue("Options", profile.Options);
data = new Dictionary<string, string>();
data.Add(NucleusFolderEnum.GameFolder.ToString(), Path.GetDirectoryName(game.ExePath));
if (gen.SaveType == GenericGameSaveType.None)
{
return true;
}
string saveFile = ProcessPath(gen.SavePath);
GameManager.Instance.BeginBackup(game.Game);
GameManager.Instance.BackupFile(game.Game, saveFile);
return true;
}
示例5: loop
public void loop()
{
string loopscript = File.ReadAllText("scripts/loop.js");
Jint.Engine jsint = new Jint.Engine();
jsint.SetValue("debuglog", new Action<object>(Console.WriteLine));
jsint.Execute(loopscript);
}
示例6: PrepareEngine
static Engine PrepareEngine(string code)
{
Engine e = new Engine(f => f.AllowClr(typeof(CDSData).Assembly));
e.SetValue("Log", new Action<Object>(Console.WriteLine)); //change to write data to a node rather than to console later
e.Execute("var CDSCommon = importNamespace('CDS.Common');");
e.Execute(code);
return e;
}
示例7: EngineInstance
public EngineInstance(IWindow window, IDictionary<String, Object> assignments)
{
_objects = new Dictionary<Object, DomNodeInstance>();
_engine = new Engine();
_engine.SetValue("console", new ConsoleInstance(_engine));
foreach (var assignment in assignments)
_engine.SetValue(assignment.Key, assignment.Value);
_window = GetDomNode(window);
_lexicals = LexicalEnvironment.NewObjectEnvironment(_engine, _window, _engine.ExecutionContext.LexicalEnvironment, true);
_variables = LexicalEnvironment.NewObjectEnvironment(_engine, _engine.Global, null, false);
_constructors = new DomConstructors(this);
_constructors.Configure();
this.AddConstructors(_window, typeof(INode));
this.AddConstructors(_window, this.GetType());
}
示例8: SetupScriptEngine
private Engine SetupScriptEngine()
{
var engine = new Engine(cfg => cfg.TimeoutInterval(TimeSpan.FromMinutes(1)));
foreach (var objectProvider in _objectProviders)
{
foreach (var tuple in objectProvider.GetObjects())
{
engine.SetValue(tuple.Item1, tuple.Item2);
}
foreach (var tuple in objectProvider.GetDelegates())
{
engine.SetValue(tuple.Item1, tuple.Item2);
}
}
return engine;
}
开发者ID:xpressive-websolutions,项目名称:Xpressive.Home.ProofOfConcept,代码行数:19,代码来源:ScriptExecutionContext.cs
示例9: CustomizeEngine
protected override void CustomizeEngine(Engine engine, ScriptedJsonPatcherOperationScope scope)
{
base.CustomizeEngine(engine, scope);
engine.SetValue("documentId", docId);
engine.SetValue("replicateTo", new Action<string,object>(ReplicateToFunction));
foreach (var sqlReplicationTable in config.SqlReplicationTables)
{
var current = sqlReplicationTable;
engine.SetValue("replicateTo" + sqlReplicationTable.TableName, (Action<object>)(cols =>
{
var tableName = current.TableName;
ReplicateToFunction(tableName, cols);
}));
}
engine.SetValue("toVarchar", (Func<string, int,ValueTypLengthTriple>)(ToVarchar));
engine.SetValue("toNVarchar", (Func<string, int, ValueTypLengthTriple>)(ToNVarchar));
}
示例10: Evaluate
public bool Evaluate(object source, Message message)
{
Engine engine = new Engine();
engine.SetValue("message", message);
engine.Execute(Script);
if (!engine.GetCompletionValue().IsBoolean())
{
return false;
}
return engine.GetCompletionValue().AsBoolean();
}
示例11: Script
public Script()
{
ConsoleNatives = new Scripting.Natives.Console();
Engine = new Engine(cfg => cfg.AllowClr(typeof(Vector2).Assembly,
typeof(Vector3).Assembly,
typeof(Vector4).Assembly,
typeof(Quaternion).Assembly));
#if SERVER
Engine.SetValue("Vector2", new Func<float, float, Vector2>((X, Y) => { return new Vector2(X, Y); }));
Engine.SetValue("Vector3", new Func<float, float, float, Vector3>((X, Y, Z) => { return new Vector3(X, Y, Z); }));
Engine.SetValue("Vector4", new Func<float, float, float, float, Vector4>((X, Y, Z, W) => { return new Vector4(X, Y, Z, W); }));
Engine.SetValue("Quaternion", new Func<float, float, float, float, Quaternion>((X, Y, Z, W) => { return new Quaternion(X, Y, Z, W); }));
#endif
#if CLIENT
Engine.SetValue("Vector2", new Func<float, float, GTA.Vector2>((X, Y) => { return new GTA.Vector2(X, Y); }));
Engine.SetValue("Vector3", new Func<float, float, float, GTA.Vector3>((X, Y, Z) => { return new GTA.Vector3(X, Y, Z); }));
Engine.SetValue("Vector4", new Func<float, float, float, float, GTA.Vector4>((X, Y, Z, W) => { return new GTA.Vector4(X, Y, Z, W); }));
Engine.SetValue("Quaternion", new Func<float, float, float, float, GTA.Quaternion>((X, Y, Z, W) => { return new GTA.Quaternion(X, Y, Z, W); }));
#endif
Engine.SetValue("Console", ConsoleNatives);
Engine.SetValue("Event", new Func<string, Scripting.Natives.EventNatives>((Name) => { return new Scripting.Natives.EventNatives(Name); }));
}
示例12: CompileMap
public MapDelegate CompileMap(string source, string language)
{
if(!language.Equals("javascript")) {
return null;
}
source = source.Replace("function", "function _f1");
return (doc, emit) =>
{
var engine = new Engine().SetValue("log", new Action<object>((line) => Log.I("JSViewCompiler", line.ToString())));
engine.SetValue("emit", emit);
engine.Execute(source).Invoke("_f1", doc);
};
}
开发者ID:transformersprimeabcxyz,项目名称:_TO-DO-couchbase-lite-net-couchbase,代码行数:15,代码来源:JSViewCompiler.cs
示例13: Load
public bool Load()
{
Unload();
if (homegenie == null)
return false;
scriptEngine = new Engine();
hgScriptingHost = new ScriptingHost();
hgScriptingHost.SetHost(homegenie, programBlock.Address);
scriptEngine.SetValue("hg", hgScriptingHost);
return true;
}
示例14: ScriptContext
object IScriptingProvider.Execute(string script, ScriptExecutionOptions options)
{
ScriptContext context = new ScriptContext(options);
Engine eng = new Engine(_ => _.Strict());
eng.SetValue("context", context);
object v = eng.Execute(script);
if (context.ret != null)
{
return context.ret;
}
return v;
}
示例15: ProcessWithJint
private object ProcessWithJint(string model, object attrs)
{
var engine = new Engine();
// engine.SetValue("model", stream.ToString());
engine.SetValue("console", new
{
log = new Action<object>(Logger.Log)
});
// throw exception when execution fails
engine.Execute(_script);
var value = engine.Invoke("transform", model, JsonUtility.Serialize(attrs)).ToObject();
// var value = engine.GetValue("model").ToObject();
// The results generated
return value;
}