本文整理汇总了C#中Jint.Engine类的典型用法代码示例。如果您正苦于以下问题:C# Engine类的具体用法?C# Engine怎么用?C# Engine使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Engine类属于Jint命名空间,在下文中一共展示了Engine类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: Plugin
public Plugin(DirectoryInfo directory, string name, string code)
{
Name = name;
Code = code;
RootDirectory = directory;
Timers = new Dictionary<String, TimedEvent>();
Engine = new Engine(cfg => cfg.AllowClr(typeof(UnityEngine.GameObject).Assembly,
typeof(uLink.NetworkPlayer).Assembly,
typeof(PlayerInventory).Assembly))
.SetValue("Server", Server.GetServer())
.SetValue("DataStore", DataStore.GetInstance())
.SetValue("Util", Util.GetUtil())
.SetValue("World", World.GetWorld())
.SetValue("Lookup", LookUp.GetLookUp())
.SetValue("Plugin", this)
.Execute(code);
Logger.LogDebug(string.Format("{0} AllowClr for Assemblies: {1} {2} {3}", brktname,
typeof(UnityEngine.GameObject).Assembly.GetName().Name,
typeof(uLink.NetworkPlayer).Assembly.GetName().Name,
typeof(PlayerInventory).Assembly.GetName().Name));
try {
Engine.Invoke("On_PluginInit");
} catch {
}
}
开发者ID:balu92,项目名称:Fougerite,代码行数:27,代码来源:JintPlugin.cs
示例2: CheckinScript
public void CheckinScript(ScriptedPatchRequest request, Engine context, RavenJObject customFunctions)
{
CachedResult cacheByCustomFunctions;
var patchRequestAndCustomFunctionsTuple = new ScriptedPatchRequestAndCustomFunctionsToken(request, customFunctions);
if (cacheDic.TryGetValue(patchRequestAndCustomFunctionsTuple, out cacheByCustomFunctions))
{
if (cacheByCustomFunctions.Queue.Count > 20)
return;
cacheByCustomFunctions.Queue.Enqueue(context);
return;
}
cacheDic.AddOrUpdate(patchRequestAndCustomFunctionsTuple, patchRequest =>
{
var queue = new ConcurrentQueue<Engine>();
return new CachedResult
{
Queue = queue,
Timestamp = SystemTime.UtcNow,
Usage = 1
};
}, (patchRequest, result) =>
{
result.Queue.Enqueue(context);
return result;
});
}
开发者ID:j2jensen,项目名称:ravendb,代码行数:28,代码来源:ScriptsCache.cs
示例3: JavaScriptPlugin
/// <summary>
/// Initializes a new instance of the JavaScriptPlugin class
/// </summary>
/// <param name="filename"></param>
/// <param name="engine"></param>
/// <param name="watcher"></param>
internal JavaScriptPlugin(string filename, Engine engine, FSWatcher watcher)
{
// Store filename
Filename = filename;
JavaScriptEngine = engine;
this.watcher = watcher;
}
开发者ID:CypressCube,项目名称:Oxide,代码行数:13,代码来源:JavaScriptPlugin.cs
示例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;
}
开发者ID:XxRaPiDK3LLERxX,项目名称:nucleuscoop,代码行数:30,代码来源:GenericGameHandler.cs
示例5: ObjectFromConfig
/// <summary>
/// Copies and translates the contents of the specified config file into the specified object
/// </summary>
/// <param name="config"></param>
/// <param name="engine"></param>
/// <returns></returns>
public static ObjectInstance ObjectFromConfig(DynamicConfigFile config, Engine engine)
{
var objInst = new ObjectInstance(engine) {Extensible = true};
foreach (var pair in config)
{
objInst.FastAddProperty(pair.Key, JsValueFromObject(pair.Value, engine), true, true, true);
}
return objInst;
}
开发者ID:906507516,项目名称:Oxide,代码行数:15,代码来源:Utility.cs
示例6: PutDocument
public override void PutDocument(string documentKey, object data, object meta, Engine engine)
{
if (forbiddenDocuments.Contains(documentKey))
throw new InvalidOperationException(string.Format("Cannot PUT document '{0}' to prevent infinite indexing loop. Avoid modifying documents that could be indirectly referenced by index.", documentKey));
base.PutDocument(documentKey, data, meta, engine);
}
开发者ID:ReginaBricker,项目名称:ravendb,代码行数:7,代码来源:ScriptedIndexResultsJsonPatcherScope.cs
示例7: PlexBinding
public PlexBinding(string username, string password)
{
_username = username;
_password = password;
this.PlayBack = new PlaybackApiBinding(Plexito.JavaScriptLogic.Scripts.PlaybackApi);
_scripts = new Engine(cfg => cfg.AllowClr(typeof(XMLHttpRequest).Assembly)).Execute(Plexito.JavaScriptLogic.Scripts.PlexApi);
}
开发者ID:salfab,项目名称:Plexito,代码行数:7,代码来源:PlexBinding.cs
示例8: CheckinScript
public void CheckinScript(ScriptedPatchRequest request, Engine context)
{
CachedResult value;
if (cacheDic.TryGetValue(request, out value))
{
if (value.Queue.Count > 20)
return;
value.Queue.Enqueue(context);
return;
}
cacheDic.AddOrUpdate(request, patchRequest =>
{
var queue = new ConcurrentQueue<Engine>();
queue.Enqueue(context);
return new CachedResult
{
Queue = queue,
Timestamp = SystemTime.UtcNow,
Usage = 1
};
}, (patchRequest, result) =>
{
result.Queue.Enqueue(context);
return result;
});
}
开发者ID:WimVergouwe,项目名称:ravendb,代码行数:26,代码来源:ScriptsCache.cs
示例9: 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);
}
开发者ID:gitter-badger,项目名称:RevEngine,代码行数:7,代码来源:Javascript.cs
示例10: JavaScriptRunner
public JavaScriptRunner(IFeedback<LogEntry> log, ICommandProcessor commandProcessor, IEntityContextConnection entityContextConnection)
{
if (log == null)
throw new ArgumentNullException(nameof(log));
if (commandProcessor == null)
throw new ArgumentNullException(nameof(commandProcessor));
if (entityContextConnection == null)
throw new ArgumentNullException(nameof(entityContextConnection));
Log = log;
CommandProcessor = commandProcessor;
EntityContextConnection = entityContextConnection;
log.Source = "JavaScript Runner";
JintEngine = new Engine(cfg =>
{
cfg.AllowClr();
cfg.AllowDebuggerStatement(JavascriptDebugEnabled);
});
//JintEngine.Step += async (s, info) =>
//{
// await Log.ReportInfoFormatAsync(CancellationToken.None, "{1} {2}",
// info.CurrentStatement.Source.Start.Line,
// info.CurrentStatement.Source.Code.Replace(Environment.NewLine, ""));
//};
}
开发者ID:ruisebastiao,项目名称:zVirtualScenes,代码行数:29,代码来源:JavaScriptRunner.cs
示例11: JSEngine
public JSEngine(Engine engine)
{
if (engine == null)
throw new ArgumentNullException(nameof(engine));
_engine = engine;
}
开发者ID:IdleLands,项目名称:IdleLandsRedux,代码行数:7,代码来源:JSEngine.cs
示例12: Run
private static void Run(string[] args)
{
var engine = new Engine(cfg => cfg.AllowClr())
.SetValue("print", new Action<object>(Print))
.SetValue("ac", _acDomain);
var filename = args.Length > 0 ? args[0] : "";
if (!String.IsNullOrEmpty(filename))
{
if (!File.Exists(filename))
{
Console.WriteLine(@"Could not find file: {0}", filename);
}
var script = File.ReadAllText(filename);
var result = engine.GetValue(engine.Execute(script).GetCompletionValue());
return;
}
Welcome();
var defaultColor = Console.ForegroundColor;
while (true)
{
Console.ForegroundColor = defaultColor;
Console.Write(@"anycmd> ");
var input = Console.ReadLine();
if (input == "exit")
{
return;
}
if (input == "clear")
{
Console.Clear();
Welcome();
continue;
}
try
{
var result = engine.GetValue(engine.Execute(string.Format("print({0})", input)).GetCompletionValue());
if (result.Type != Types.None && result.Type != Types.Null && result.Type != Types.Undefined)
{
var str = TypeConverter.ToString(engine.Json.Stringify(engine.Json, Arguments.From(result, Undefined.Instance, " ")));
Console.WriteLine(@"=> {0}", str);
}
}
catch (JavaScriptException je)
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine(je.ToString());
}
catch (Exception e)
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine(e.Message);
}
}
}
开发者ID:mingkongbin,项目名称:anycmd,代码行数:59,代码来源:Program.cs
示例13: JavascriptContext
public JavascriptContext(string script, string errorMessageContext)
{
_engine = new Engine();
_errorMessageContext = errorMessageContext;
_initialJavascript = script;
Initialize(_initialJavascript);
}
开发者ID:GrowingData,项目名称:Mung,代码行数:8,代码来源:JavascriptContext.cs
示例14: Echo
private static int Echo(Engine scriptScope, object echoStr)
{
var response = (ClientHttpResponse) scriptScope.GetValue("response").ToObject();
if (!response.HasFinishedSendingHeaders)
response.SendDefaultHeaders();
response.OutputStream.WriteLine(echoStr.ToString());
return 0;
}
开发者ID:CookieEaters,项目名称:FireHTTP,代码行数:8,代码来源:WebUtils.cs
示例15: 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;
}
开发者ID:Threadnaught,项目名称:CDS,代码行数:8,代码来源:CDSCode.cs
示例16: GetCryPwd
static string GetCryPwd(string pwd)
{
var engine = new Engine()
.Execute(@"function mc(a){ret='';var b='0123456789ABCDEF';if(a==' '.charCodeAt()){ret='+'}else if((a<'0'.charCodeAt()&&a!='-'.charCodeAt()&&a!='.'.charCodeAt())||(a<'A'.charCodeAt()&&a>'9'.charCodeAt())||(a>'Z'.charCodeAt()&&a<'a'.charCodeAt()&&a!='_'.charCodeAt())||(a>'z'.charCodeAt())){ret='%';ret+=b.charAt(a>>4);ret+=b.charAt(a&15)}else{ret=String.fromCharCode(a)};return ret};function m(a){return(((a&1)<<7)|((a&(0x2))<<5)|((a&(0x4))<<3)|((a&(0x8))<<1)|((a&(0x10))>>1)|((a&(0x20))>>3)|((a&(0x40))>>5)|((a&(0x80))>>7))};function md6(a){var b='';var c=0xbb;for(i=0;i<a.length;i++){c=m(a.charCodeAt(i))^(0x35^(i&0xff));var d=c.toString(16);b+=mc(c)};return b}");
var value = engine.Invoke("md6", pwd);
return value.ToString();
}
开发者ID:wangchunlei,项目名称:MyGit,代码行数:8,代码来源:Program.cs
示例17: JavaScriptPlugin
/// <summary>
/// Initializes a new instance of the JavaScriptPlugin class
/// </summary>
/// <param name="filename"></param>
/// <param name="engine"></param>
/// <param name="watcher"></param>
internal JavaScriptPlugin(string filename, Engine engine, FSWatcher watcher)
{
// Store filename
Filename = filename;
Name = Core.Utility.GetFileNameWithoutExtension(Filename);
JavaScriptEngine = engine;
this.watcher = watcher;
}
开发者ID:zakharovg,项目名称:Oxide,代码行数:14,代码来源:JavaScriptPlugin.cs
示例18: CoffeeScriptPluginLoader
/// <summary>
/// Initializes a new instance of the CoffeeScriptPluginLoader class
/// </summary>
/// <param name="engine"></param>
public CoffeeScriptPluginLoader(Engine engine)
{
JavaScriptEngine = engine;
using (var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(compilerResourcePath))
using (var reader = new StreamReader(stream))
engine.Execute(reader.ReadToEnd(), new ParserOptions { Source = "CoffeeScriptCompiler" });
engine.Execute("function __CompileScript(name){return CoffeeScript.compile(name+\"=\\n\"+__CoffeeSource.replace(/^/gm, ' '),{bare: true})}");
}
开发者ID:906507516,项目名称:Oxide,代码行数:13,代码来源:CoffeeScriptPluginLoader.cs
示例19: ToJSArray
//Arrays cannot simply be passed into the Javascript engine, they must be allocated
//according to Javascript rules
private static ArrayInstance ToJSArray(IEnumerable list, Engine engine)
{
List<JsValue> wrappedVals = new List<JsValue>();
foreach (object x in list) {
wrappedVals.Add(JsValue.FromObject(engine, x));
}
return (ArrayInstance)engine.Array.Construct(wrappedVals.ToArray());
}
开发者ID:ertrupti9,项目名称:couchbase-lite-net,代码行数:11,代码来源:JSViewCompiler.cs
示例20: 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)));
}
开发者ID:CookieEaters,项目名称:FireHTTP,代码行数:9,代码来源:WebUtils.cs
注:本文中的Jint.Engine类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论