Inheritance: IScriptEngine
Ejemplo n.º 1
0
        public ScriptServices Build(IRepl repl)
        {
            //TODO: this need to be wired up properly using our own IoC container from caliburn.

            var underlyingLogger = LogManager.GetCurrentClassLogger();
            var replLogger = new ReplLogger(LogLevel.Info, repl, underlyingLogger);
            ILog logger = replLogger;

            var fileSystem = new FileSystem();
            var engine = new RoslynScriptEngine(new ReplScriptHostFactory(), logger);
            var filePreProcessor = new FilePreProcessor(fileSystem, logger, new ILineProcessor[] {new LoadLineProcessor(fileSystem), new ReferenceLineProcessor(fileSystem), new UsingLineProcessor() });
            var packageAssemblyResolver = new PackageAssemblyResolver(fileSystem, new PackageContainer(fileSystem, logger), logger);
            var installationProvider = new NugetInstallationProvider(fileSystem, logger);

            return new ScriptServices(
                fileSystem,
                packageAssemblyResolver,
                new ScriptExecutor(fileSystem, filePreProcessor, engine, logger),
                engine,
                filePreProcessor,
                new ScriptPackResolver(new IScriptPack[0]),
                new PackageInstaller(installationProvider, logger),
                null, //IObjectSerializer
                logger,
                new AssemblyResolver(fileSystem, packageAssemblyResolver, new AssemblyUtility(), logger),
                null, //IConsole
                installationProvider
                );
        }
        public static ScriptCSSession Create(Cmdlet cmdlet)
        {
            ScriptCSSession session = null;
            var logger = new CurrentLogger();

            using (logger.CreateActiveLoggerSession(new CmdletLogger(cmdlet)))
            {
                IScriptHostFactory factory = new ScriptHostFactory();
                var engine = new RoslynScriptEngine(factory, logger);
                engine.BaseDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
                var currentCmdletScriptPack = new CurrentCmdletScriptPack();
                var scriptPackSession = new ScriptPackSession(new IScriptPack[] { currentCmdletScriptPack });
                scriptPackSession.InitializePacks();

                session = new ScriptCSSession( engine, scriptPackSession, currentCmdletScriptPack, logger );
            }

            return session;
        }