Exemple #1
0
        public async Task <TReturn> Execute <TReturn>(ExecuteLibraryCommandOptions options)
        {
            if (!File.Exists(options.LibraryPath))
            {
                throw new Exception($"Couldn't find file '{options.LibraryPath}'");
            }

            var absoluteFilePath = options.LibraryPath.GetRootedPath();
            var compiler         = GetScriptCompiler(!options.NoCache, _logFactory);
            var runner           = new ScriptRunner(compiler, _logFactory, _scriptConsole);
            var result           = await runner.Execute <TReturn>(absoluteFilePath, options.Arguments);

            return(result);
        }
Exemple #2
0
        public async Task <TReturn> Run <TReturn, THost>(ExecuteScriptCommandOptions options)
        {
            if (options.File.IsRemote)
            {
                return(await DownloadAndRunCode <TReturn>(options));
            }

            var pathToLibrary = GetLibrary(options);

            var libraryOptions = new ExecuteLibraryCommandOptions(pathToLibrary, options.Arguments, options.NoCache)
            {
#if NETCOREAPP
                AssemblyLoadContext = options.AssemblyLoadContext
#endif
            };

            return(await new ExecuteLibraryCommand(_scriptConsole, _logFactory).Execute <TReturn>(libraryOptions));
        }
Exemple #3
0
        private async Task <TReturn> ExecuteLibrary <TReturn>(string pathToLibrary, string[] arguments, bool noCache)
        {
            var options = new ExecuteLibraryCommandOptions(pathToLibrary, arguments, noCache);

            return(await new ExecuteLibraryCommand(_scriptConsole, _logFactory).Execute <TReturn>(options));
        }