Пример #1
0
        public void Initialize()
        {
            var builder = new ContainerBuilder();

            var loggerConfigurator = new LoggerConfigurator(_logLevel);

            loggerConfigurator.Configure();
            var logger = loggerConfigurator.GetLogger();

            builder.RegisterInstance <ILog>(logger);

            var types = new[]
            {
                typeof(ScriptHostFactory),
                typeof(FileSystem),
                typeof(PackageAssemblyResolver),
                typeof(PackageContainer),
                typeof(FilePreProcessor),
                typeof(ScriptPackResolver),
                typeof(NugetInstallationProvider),
                typeof(PackageInstaller),
                typeof(ReplConsole)
            };

            builder.RegisterTypes(types).AsImplementedInterfaces();

            if (_debug)
            {
                builder.RegisterType <DebugScriptExecutor>().As <IScriptExecutor>();
                builder.RegisterType <RoslynScriptDebuggerEngine>().As <IScriptEngine>();
            }
            else
            {
                builder.RegisterType <ScriptExecutor>().As <IScriptExecutor>();
                builder.RegisterType <RoslynScriptEngine>().As <IScriptEngine>();
            }

            builder.RegisterType <ScriptServiceRoot>().As <ScriptServiceRoot>();

            if (_shouldInitDrirectoryCatalog)
            {
                var scriptPath = Path.Combine(Environment.CurrentDirectory, "bin");
                if (Directory.Exists(scriptPath))
                {
                    var catalog = new DirectoryCatalog(scriptPath);
                    builder.RegisterComposablePartCatalog(catalog);
                }
            }
            _container         = builder.Build();
            _scriptServiceRoot = _container.Resolve <ScriptServiceRoot>();
        }
Пример #2
0
        public void Initialize()
        {
            var builder = new ContainerBuilder();
            var types = new[]
                {
                    typeof (ScriptHostFactory),
                    typeof (FileSystem),
                    typeof (PackageAssemblyResolver),
                    typeof (PackageContainer),
                    typeof (FilePreProcessor),
                    typeof (ScriptPackResolver),
                    typeof (NugetInstallationProvider),
                    typeof (PackageInstaller)
                };

            builder.RegisterTypes(types).AsImplementedInterfaces();

            if (_debug)
            {
                builder.RegisterType<DebugScriptExecutor>().As<IScriptExecutor>();
                builder.RegisterType<RoslynScriptDebuggerEngine>().As<IScriptEngine>();
            }
            else
            {
                builder.RegisterType<ScriptExecutor>().As<IScriptExecutor>();
                builder.RegisterType<RoslynScriptEngine>().As<IScriptEngine>();
            }

            builder.RegisterType<ScriptServiceRoot>().As<ScriptServiceRoot>();

            if (_shouldInitDrirectoryCatalog)
            {
                var scriptPath = Path.Combine(Environment.CurrentDirectory, "bin");
                if (Directory.Exists(scriptPath))
                {
                    var catalog = new DirectoryCatalog(scriptPath);
                    builder.RegisterComposablePartCatalog(catalog);
                }
            }
            _container = builder.Build();
            _scriptServiceRoot = _container.Resolve<ScriptServiceRoot>();
        }