Exemple #1
0
        protected override ScriptProvider <TScript> LoadScript()
        {
            if (disposedValue)
            {
                throw new ObjectDisposedException(nameof(ScriptContainerAppDomain <TScript>));
            }

            try
            {
                var assemblyPath = Path.Combine(CompiledScriptsPath, $"{Guid.NewGuid().ToString()}.dll");
                ScriptCompiler.Compile(SourcePaths, assemblyPath, ReferencedAssemblies);

                workerProcess?.Dispose();
                workerProcess = new RemoteProcessWorkerContainer();

                var scriptProvider = workerProcess.Worker.CreateScriptProvider <TScript>();
                scriptProvider.Initialize(assemblyPath, ScriptTypeName);

                return(scriptProvider);
            }
            catch (ScriptCompilationException)
            {
                throw;
            }
            catch (Exception e)
            {
                throw CreateScriptLoadingException(e);
            }
        }