public object LoadFromFile(ISimpleConfig config, string path) { var fileSystem = new FileSystem { CurrentDirectory = AppDomain.CurrentDomain.SetupInformation.ApplicationBase }; log.InfoFormat(CultureInfo.InvariantCulture, "Executing '{0}'", fileSystem.GetFullPath(path)); log.DebugFormat(CultureInfo.InvariantCulture, "The current directory is {0}", fileSystem.CurrentDirectory); var scriptCsLog = LogManager.GetLogger("ScriptCs"); var lineProcessors = new ILineProcessor[] { new LoadLineProcessor(fileSystem), new ReferenceLineProcessor(fileSystem), new UsingLineProcessor(), }; var filePreProcessor = new FilePreProcessor(fileSystem, scriptCsLog, lineProcessors); var engine = new RoslynScriptInMemoryEngine(new ConfigRScriptHostFactory(config), scriptCsLog); var executor = new ConfigRScriptExecutor(fileSystem, filePreProcessor, engine, scriptCsLog); executor.AddReferenceAndImportNamespaces(new[] { typeof(Config), typeof(IScriptHost) }); ScriptResult result; executor.Initialize(new string[0], new IScriptPack[0]); try { result = executor.Execute(path); } finally { executor.Terminate(); } RethrowExceptionIfAny(result, path); return result.ReturnValue; }
public object LoadFromFile(ISimpleConfig config, string path) { var fileSystem = new FileSystem { CurrentDirectory = AppDomain.CurrentDomain.SetupInformation.ApplicationBase }; log.InfoFormat(CultureInfo.InvariantCulture, "Executing '{0}'", fileSystem.GetFullPath(path)); log.DebugFormat(CultureInfo.InvariantCulture, "The current directory is {0}", fileSystem.CurrentDirectory); var scriptCsLog = LogManager.GetLogger("ScriptCs"); var lineProcessors = new ILineProcessor[] { new LoadLineProcessor(fileSystem), new ReferenceLineProcessor(fileSystem), new UsingLineProcessor(), }; var filePreProcessor = new FilePreProcessor(fileSystem, scriptCsLog, lineProcessors); var engine = new RoslynScriptInMemoryEngine(new ConfigRScriptHostFactory(config), scriptCsLog); var executor = new ConfigRScriptExecutor(fileSystem, filePreProcessor, engine, scriptCsLog); executor.AddReferenceAndImportNamespaces(new[] { typeof(Config), typeof(IScriptHost) }); executor.AddReferences(this.references); ScriptResult result; executor.Initialize(new string[0], new IScriptPack[0]); try { result = executor.Execute(path); } finally { executor.Terminate(); } RethrowExceptionIfAny(result, path); return(result.ReturnValue); }