本文整理汇总了C#中ScriptOptions.WithPath方法的典型用法代码示例。如果您正苦于以下问题:C# ScriptOptions.WithPath方法的具体用法?C# ScriptOptions.WithPath怎么用?C# ScriptOptions.WithPath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ScriptOptions
的用法示例。
在下文中一共展示了ScriptOptions.WithPath方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RunScript
private int RunScript(ScriptOptions options, string code, string scriptPath, ErrorLogger errorLogger, CancellationToken cancellationToken)
{
var globals = new CommandLineScriptGlobals(_console.Out, _objectFormatter);
globals.Args.AddRange(_compiler.Arguments.ScriptArguments);
options = options.WithPath(scriptPath).WithIsInteractive(false);
var script = Script.CreateInitialScript<object>(_scriptCompiler, code, options, globals.GetType(), assemblyLoaderOpt: null);
try
{
script.RunAsync(globals, cancellationToken).Wait();
// TODO: use the return value of the script https://github.com/dotnet/roslyn/issues/5773
return CommonCompiler.Succeeded;
}
catch (CompilationErrorException e)
{
_compiler.ReportErrors(e.Diagnostics, _console.Out, errorLogger);
return CommonCompiler.Failed;
}
}
示例2: RunScript
private void RunScript(ScriptOptions options, string code, string scriptPath, CommandLineHostObject globals, ErrorLogger errorLogger)
{
options = options.WithPath(scriptPath).WithIsInteractive(false);
var script = Script.CreateInitialScript<object>(_scriptCompiler, code, options, globals.GetType(), assemblyLoaderOpt: null);
try
{
script.RunAsync(globals, globals.CancellationToken).Wait();
}
catch (CompilationErrorException e)
{
_compiler.ReportErrors(e.Diagnostics, _console.Out, errorLogger);
globals.ExitCode = CommonCompiler.Failed;
}
}