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


C# IScriptEngine.Execute方法代码示例

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


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

示例1: ExecuteScript

 private CalamariResult ExecuteScript(IScriptEngine psse, string scriptName, CalamariVariableDictionary variables)
 {
     var capture = new CaptureCommandOutput();
     var runner = new CommandLineRunner(capture);
     var result = psse.Execute(scriptName, variables, runner);
     return new CalamariResult(result.ExitCode, capture);
 }
开发者ID:bjewell52,项目名称:Calamari,代码行数:7,代码来源:ScriptEngineFixture.cs

示例2: Run

        public string Run(IScriptEngine engine, string[] args)
        {
            PrepareConsole();
            var core = CreateCore(engine);
            var evaluator = core.Evaluator;
            var stdin = new StandardInputStream(evaluator, ConsoleColor.Green);
            core.AddNativeModule("stdin", stdin);
            SetOutputs(core);
            if (args == null || args.Length == 0)
            {
                core.Sleep();
            }
            else if (args.Length == 1)
            {
                var path = "/" + args[0];
                try
                {
                    core.Run(path);
                }
                catch
                {
                    core.Sleep();
                }
            }
            else if (args.Length > 1)
            {
                evaluator.Execute("args = []");
                var init = string.Empty;
                var length = args.Length;
                for (var i = 0; i < length; i++)
                {
                    var arg = args[i];
                    var name = $"arg{i + 1}";
                    engine.Script[name] = arg;
                    init += $"args.push({name});";
                }

                evaluator.Execute(init);
            }

            if (core.Sleeping)
            {
                core.ExposeGlobalRequire();
                engine.Execute("require('repl').hook(require('stdin'))");
                stdin.Run();
            }

            return null;
        }
开发者ID:furesoft,项目名称:RShipCore,代码行数:49,代码来源:RShipLoader.cs

示例3: SetUp

        public void SetUp()
        {
            fileSystem = Substitute.For<ICalamariFileSystem>();
            fileSystem.EnumerateFiles(Arg.Any<string>(), Arg.Any<string[]>()).Returns(new[]
            {
                TestEnvironment.ConstructRootedPath("App", "MyApp", "Hello.ps1"),
                TestEnvironment.ConstructRootedPath("App", "MyApp", "Deploy.ps1"),
                TestEnvironment.ConstructRootedPath("App", "MyApp", "Deploy.csx"),
                TestEnvironment.ConstructRootedPath("App", "MyApp", "PreDeploy.ps1")
            });

            commandResult = new CommandResult("PowerShell.exe foo bar", 0, null);
            scriptEngine = Substitute.For<IScriptEngine>();
            scriptEngine.Execute(Arg.Any<string>(), Arg.Any<CalamariVariableDictionary>(), Arg.Any<ICommandLineRunner>()).Returns(c => commandResult);
            scriptEngine.GetSupportedExtensions().Returns(new[] {"csx", "ps1"});
            runner = Substitute.For<ICommandLineRunner>();
            deployment = new RunningDeployment(TestEnvironment.ConstructRootedPath("Packages"), new CalamariVariableDictionary());
        }
开发者ID:enlightendesigns,项目名称:Calamari,代码行数:18,代码来源:PackagedScriptConventionFixture.cs

示例4: ExecuteScript

        public CommandResult ExecuteScript(IScriptEngine scriptEngine, string scriptFile, CalamariVariableDictionary variables, ICommandLineRunner commandLineRunner)
        {
            var workingDirectory = Path.GetDirectoryName(scriptFile);
            variables.Set("OctopusAzureTargetScript", scriptFile);

            // If the Azure PowerShell module to use has not been explicitly configured, then default to the version
            // bundled with Calamari
            SetOutputVariable(SpecialVariables.Action.Azure.Output.ModulePath,
                variables.Get(SpecialVariables.Action.Azure.PowerShellModulePath, BuiltInAzurePowershellModulePath), variables);

            SetOutputVariable(SpecialVariables.Action.Azure.Output.SubscriptionId, variables.Get(SpecialVariables.Action.Azure.SubscriptionId), variables);
            SetOutputVariable(SpecialVariables.Action.Azure.Output.SubscriptionName, variables.Get(SpecialVariables.Account.Name), variables);

            using (new TemporaryFile(CreateAzureCertificate(workingDirectory, variables)))
            using (var contextScriptFile = new TemporaryFile(CreateContextScriptFile(workingDirectory)))
            {
                return scriptEngine.Execute(contextScriptFile.FilePath, variables, commandLineRunner);
            }
        }
开发者ID:elevate,项目名称:Calamari,代码行数:19,代码来源:AzurePowershellContext.cs


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