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


C# Engine.Invoke方法代码示例

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


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

示例3: CompileReduce

        public ReduceDelegate CompileReduce(string source, string language)
        {
            if(!language.Equals("javascript")) {
                return null;
            }

            if (source.StartsWith("_")) {
                return BuiltinReduceFunctions.Get(source.TrimStart('_'));
            }

            source = source.Replace("function", "function _f2");
            var engine = new Engine().Execute(source).SetValue("log", new Action<object>((line) => Log.I("JSViewCompiler", line.ToString())));

            return (keys, values, rereduce) => {
                var result = engine.Invoke("_f2", keys, values, rereduce);
                return result.ToObject();
            };
        }
开发者ID:transformersprimeabcxyz,项目名称:_TO-DO-couchbase-lite-net-couchbase,代码行数:18,代码来源:JSViewCompiler.cs

示例4: 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;
        }
开发者ID:yonglehou,项目名称:docfx,代码行数:18,代码来源:Template.cs

示例5: Transform

        private static void Transform(JintPluginsStore plugins)
        {
            var engine = new Engine();
            engine.UsePlugins("ais", plugins);

            engine.Execute(@"
                function hello() {

                return ais.TestPlugin.Test('dsadsa');
                };
            ");

            try
            {
                var hello = engine.Invoke("hello");
                Console.WriteLine(hello);
            }
            catch (TargetInvocationException e)
            {
                ExceptionDispatchInfo.Capture(e.InnerException).Throw();
            }
        }
开发者ID:terianil,项目名称:JintPlugins,代码行数:22,代码来源:Program.cs

示例6: OutputLog

		private void OutputLog(Engine engine)
		{
			var arr = engine.GetValue("debug_outputs");
			if (arr == JsValue.Null || arr.IsArray() == false)
				return;

			foreach (var property in arr.AsArray().Properties)
			{
				if (property.Key == "length")
					continue;

				var jsInstance = property.Value.Value;
				if (!jsInstance.HasValue)
					continue;

				var output = jsInstance.Value.IsNumber() ? jsInstance.Value.AsNumber().ToString() : jsInstance.Value.AsString();

				Debug.Add(output);
			}

			engine.Invoke("clear_debug_outputs");
		}
开发者ID:ReginaBricker,项目名称:ravendb,代码行数:22,代码来源:ScriptedJsonPatcher.cs

示例7: OutputLog

		private void OutputLog(Engine engine)
		{
			var arr = engine.GetValue("debug_outputs");
			if (arr == JsValue.Null || arr.IsArray() == false)
				return;

			foreach (var property in arr.AsArray().Properties)
			{
				if (property.Key == "length")
					continue;

				var jsInstance = property.Value.Value;
				if (!jsInstance.HasValue)
					continue;				
				
				var output = jsInstance.Value.IsNumber() ? 
					jsInstance.Value.AsNumber().ToString(CultureInfo.InvariantCulture) : 
								(jsInstance.Value.IsBoolean() ? //if the parameter is boolean, we need to take it into account, 
																//since jsInstance.Value.AsString() will not work for boolean values
										jsInstance.Value.AsBoolean().ToString() : 
										jsInstance.Value.AsString());

				Debug.Add(output);
			}

			engine.Invoke("clear_debug_outputs");
		}
开发者ID:felipeleusin,项目名称:ravendb,代码行数:27,代码来源:ScriptedJsonPatcher.cs

示例8: OutputLog

        private void OutputLog(Engine engine)
        {
            var arr = engine.GetValue("debug_outputs");
            if (arr == JsValue.Null || arr.IsArray() == false)
                return;

            foreach (var property in arr.AsArray().Properties)
            {
                if (property.Key == "length")
                    continue;

                var jsInstance = property.Value.Value;
                if (!jsInstance.HasValue)
                    continue;

                var value = jsInstance.Value;
                string output = null;
                switch (value.Type)
                {
                    case Types.Boolean:
                        output = value.AsBoolean().ToString();
                        break;
                    case Types.Null:
                    case Types.Undefined:
                        output = value.ToString();
                        break;
                    case Types.Number:
                        output = value.AsNumber().ToString(CultureInfo.InvariantCulture);
                        break;
                    case Types.String:
                        output = value.AsString();
                        break;
                }

                if (output != null)
                    Debug.Add(output);
            }

            engine.Invoke("clear_debug_outputs");
        }
开发者ID:j2jensen,项目名称:ravendb,代码行数:40,代码来源:ScriptedJsonPatcher.cs


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