Beispiel #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);
            }
        }
Beispiel #2
0
 protected override void Dispose(bool disposing)
 {
     if (!disposedValue)
     {
         if (disposing)
         {
             workerProcess?.Dispose();
         }
         workerProcess = null;
         disposedValue = true;
     }
     base.Dispose(disposing);
 }