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


C# ScriptEngine.ExecuteFile方法代码示例

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


在下文中一共展示了ScriptEngine.ExecuteFile方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ReadAllTasks

        public static ICollection<string> ReadAllTasks(string path)
        {
            var list = new List<string>();

            if (path.EndsWith(".ts"))
            {
                path = path.Replace(".ts", ".js").Replace(".coffee",".js");
            }

            if (!File.Exists(path))
            {
                return list;
            }

            // executes the gulpfile with some little additions :)
            try
            {
                var engine = new ScriptEngine();
                engine.Execute(Resources.gulpInit);
                engine.ExecuteFile(path);

                // reads the evaluated tasks
                ArrayInstance names = (ArrayInstance)engine.Evaluate("tasks");
                foreach (var elem in names.ElementValues)
                {
                    list.Add((string)elem);
                }
            }
            catch (Exception)
            {
                list.Add("Cannot parse gulpfile");
            }

            return list.Distinct().ToList();
        }
开发者ID:brucethwaits,项目名称:GruntLauncher,代码行数:35,代码来源:GulpParser.cs

示例2: Execute

        public override void Execute(ScriptEngine scriptEngine)
        {
            if (scriptEngine == null)
                throw new ArgumentNullException("scriptEngine");

            scriptEngine.ExecuteFile(_scriptPath);
        }
开发者ID:JogoShugh,项目名称:IronRubyMef,代码行数:7,代码来源:RubyPartFile.cs

示例3: InitEngine

    protected void InitEngine()
    {
        JSEngine = new Jurassic.ScriptEngine();
        FileToExecute = FileToExecute.Select(i => filePath + "\\" + i).ToList();

        FileToExecute.ForEach(file => JSEngine.ExecuteFile(file));
    }
开发者ID:zcxp,项目名称:Wind.js-VS-Add-in,代码行数:7,代码来源:ScriptConvertor.cs

示例4: Execute

 public override void Execute(ScriptEngine engine, ScriptScope scope)
 {
     if (!string.IsNullOrEmpty(Path))
     {
         engine.ExecuteFile(Path, scope);
     }
 }
开发者ID:torshy,项目名称:FileReplicator,代码行数:7,代码来源:ScriptFile.cs

示例5: ReadAllTasks

        /// <summary>
        /// Reads all the defined tasks in a Gruntfile whose path is passed as parameter
        /// </summary>
        /// <param name="path">The path of the  file to examine</param>
        /// <returns>A list of tasks</returns>
        public static ICollection<string> ReadAllTasks(string path)
        {
            var list = new List<string>();

            //executes the gruntfile with some little additions :)
            try
            {
                var engine = new ScriptEngine();
                engine.Execute(Resources.Init);
                engine.ExecuteFile(path);
                engine.Execute("module.exports(grunt);");

                //reads the evaluated tasks
                ArrayInstance names = (ArrayInstance)engine.Evaluate("names");
                foreach (var elem in names.ElementValues)
                {
                    list.Add((string)elem);
                }
            }
            catch (Exception) {
                list.Add("Cannot parse Gruntfile");
            }

            return list;
        }
开发者ID:kojoru,项目名称:GruntLauncher,代码行数:30,代码来源:GruntParser.cs

示例6: LoadHtmlTemplateScriptsIntoEngine

 static ScriptEngine LoadHtmlTemplateScriptsIntoEngine(HtmlTemplateBundle bundle)
 {
     var output = bundle.OpenStream().ReadToEnd();
     var scriptEngine = new ScriptEngine();
     scriptEngine.ExecuteFile("hogan.js");
     scriptEngine.Execute(output);
     return scriptEngine;
 }
开发者ID:prabirshrestha,项目名称:cassette,代码行数:8,代码来源:HoganPipeline.cs

示例7: BigNumber

 public void BigNumber()
 {
     var engine = new ScriptEngine();
     engine.SetGlobalValue("console", new Jurassic.Library.FirebugConsole(engine));
     engine.ExecuteFile(@"..\..\..\Unit Tests\Real-world\Files\bignumber.js");
     engine.EnableDebugging = true;
     Assert.AreEqual("129963294281830400", engine.Evaluate(@"new BigNumber('129963294281830401').subtract(1).toString()"));
 }
开发者ID:paulbartrum,项目名称:jurassic,代码行数:8,代码来源:RealWorldTests.cs

示例8: Script

 public Script(string path)
 {
     _engine = Python.CreateEngine();
     _engine.Runtime.LoadAssembly(Assembly.GetExecutingAssembly());
     _path = Path.Combine("Content/Scripts/", path + ".py");
     _scope = _engine.CreateScope();
     _scope.owner = this;
     _engine.ExecuteFile(_path, _scope);
     _scriptClass = _engine.Operations.CreateInstance(_scope.GetVariable("Script"));
     _engine.Operations.InvokeMember(_scriptClass, "initialize");
 }
开发者ID:Bribz,项目名称:SpeedCodingZelda,代码行数:11,代码来源:Script.cs

示例9: Construct

        /// <summary>
        /// Creates and configures a Jurassic ScriptEngine
        /// </summary>
        /// <param name="context">The request/response context to process</param>
        /// <returns>A RaptorJS-configured Jurassic ScriptEngine instance</returns>
        public static ScriptEngine Construct(HttpListenerContext context)
        {
            ScriptEngine engine = new ScriptEngine();

            engine.SetGlobalValue("Request", new RequestInstance(engine, context.Request));
            engine.SetGlobalValue("Response", new ResponseInstance(engine, context.Response));
            engine.SetGlobalValue("console", new ConsoleInstance(engine));
            engine.SetGlobalValue("file", new FileSystemInstance(engine));

            engine.SetGlobalFunction("require", new Action<string>((path) => engine.ExecuteFile(path)));
            engine.SetGlobalFunction("require", new Func<string, object>((path) => engine.Evaluate(new FileScriptSource(path))));

            return engine;
        }
开发者ID:tmcnab,项目名称:RaptorJS,代码行数:19,代码来源:ScriptEngineFactory.cs

示例10: GaudiPythonPlugin

 public GaudiPythonPlugin(string plugin)
 {
     try
     {
         iPy = Python.CreateEngine();
         iPy.CreateScope();
         iPy.ExecuteFile(String.Format("{0}.py", plugin));
     }
     catch (Exception ex)
     {
         PrintError(String.Format("Script error - {0}.", ex.Message));
         LogDump(ex.Message);
     }
 }
开发者ID:stpettersens,项目名称:nGaudi,代码行数:14,代码来源:GaudiPythonPlugin.cs

示例11: CanCompileHoganTemplate

        public void CanCompileHoganTemplate()
        {
            var compiler = new HoganCompiler();
            var result = compiler.Compile("Hello {{world}}", new CompileContext());
            
            var engine = new ScriptEngine();
            engine.ExecuteFile("hogan.js");
            var source = @"
(function(){
var template = new Hogan.Template();
template.r = " + result.Output + @";
return template.render({world:'Andrew'});
}());";
            var templateRender = engine.Evaluate<string>(source);

            templateRender.ShouldEqual("Hello Andrew");
        }
开发者ID:jlopresti,项目名称:cassette,代码行数:17,代码来源:HoganCompiler.cs

示例12: CanCompileHandlebarsTemplate

        public void CanCompileHandlebarsTemplate()
        {
            var settings = new HandlebarsSettings { KnownHelpersOnly = false, KnownHelpers = new List<string> { "t" } };

            var compiler = new HandlebarsCompiler(settings);
            var result = compiler.Compile("Hello {{world}}", new CompileContext());

            var engine = new ScriptEngine();
            engine.ExecuteFile("handlebars.js");
            var source = @"
            (function(){
            var template = new Hogan.template(" + result.Output + @");
            return template({world:'Andrew'});
            }());";
            var templateRender = engine.Evaluate<string>(source);

            templateRender.ShouldEqual("Hello Andrew");
        }
开发者ID:jpsullivan,项目名称:cassette,代码行数:18,代码来源:HandlebarsCompiler.cs

示例13: Setup

        public void Setup()
        {
            engine = new ScriptEngine { EnableDebugging = true };
            engine.SetGlobalValue("nativeModule", new NativeModuleInstance(engine));
            engine.SetGlobalValue("console", new FirebugConsole(engine));
            engine.SetGlobalFunction("native_require", new Func<string, ObjectInstance>(identifier =>
            {
                switch (identifier)
                {
                    case "nativeModule":
                        return new NativeModuleInstance(engine);
                    default:
                        throw new ArgumentOutOfRangeException(string.Format("Unsupported module name: {0}", identifier));
                }
            }));

            engine.ExecuteFile("./Builtin/require.js");
        }
开发者ID:schultyy,项目名称:blackMagic,代码行数:18,代码来源:RequireTest.cs

示例14: EngineRun

        private void EngineRun() {
            lock(_pyLock) {
                _pyEngine = Python.CreateEngine();
                _pyEngine.Runtime.IO.SetOutput(_engineOutput, new StreamWriter(_engineOutput, System.Text.Encoding.UTF8));
                ICollection<string> paths = _pyEngine.GetSearchPaths();
                string path = Path.GetDirectoryName(_filePath);
                _logger.Log(path);
                paths.Add(path);
                _pyEngine.SetSearchPaths(paths);

                _pyScope = _pyEngine.CreateScope();
            }

            _logger.Log("Engine started. Initializing TerminalOS.");
            try {
                _pyEngine.ExecuteFile(_filePath, _pyScope);
            }
            catch (Exception e) {
                _logger.Log(e.Message + e.StackTrace);
            }

            _logger.Log("TerminalOS has stopped.");
        }
开发者ID:BrianErikson,项目名称:ScriptingTheGame,代码行数:23,代码来源:TerminalOS.cs

示例15: TestFoo

        public TestFoo()
        {
#if SILVERLIGHT
            var setup = DynamicApplication.CreateRuntimeSetup();
#else
            var setup = Python.CreateRuntimeSetup(new Dictionary<string, object>());
#endif
            setup.DebugMode = System.Diagnostics.Debugger.IsAttached;

            var runtime = new ScriptRuntime(setup);
            engine = Python.GetEngine(runtime);

			var file = "test_example.py";
#if SILVERLIGHT
			var filepath = file;
#else
            var assemblyPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
            var filepath = Path.Combine(assemblyPath, file);       
#endif
            module = engine.ExecuteFile(filepath);

            klass = engine.Operations.GetMember(module, "TestFoo");
            klassInstance = ((dynamic)klass)();
        }
开发者ID:jschementi,项目名称:ironpython-mstest,代码行数:24,代码来源:test_example.cs


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