当前位置: 首页>>代码示例>>C#>>正文


C# Jint.Engine类代码示例

本文整理汇总了C#中Jint.Engine的典型用法代码示例。如果您正苦于以下问题:C# Engine类的具体用法?C# Engine怎么用?C# Engine使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Engine类属于Jint命名空间,在下文中一共展示了Engine类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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


注:本文中的Jint.Engine类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。