Exemple #1
0
        public Program([NotNull] IServiceProvider dnxServices)
        {
            Check.NotNull(dnxServices, nameof(dnxServices));

            var appEnv = dnxServices.GetRequiredService<IApplicationEnvironment>();
            var runtimeEnv = dnxServices.GetRequiredService<IRuntimeEnvironment>();
            _applicationShutdown = dnxServices.GetRequiredService<IApplicationShutdown>();
            _useConsoleColors = runtimeEnv.OperatingSystem == "Windows";

            var loggerProvider = new LoggerProvider(name => new ConsoleCommandLogger(name, verbose: true));
            _logger = new LazyRef<ILogger>(() => loggerProvider.CreateCommandsLogger());

            var targetName = appEnv.ApplicationName;
            var startupTargetName = appEnv.ApplicationName;
            var projectDir = appEnv.ApplicationBasePath;
            var rootNamespace = appEnv.ApplicationName;

            _contextOperations = new LazyRef<DbContextOperations>(
                () => new DbContextOperations(
                    loggerProvider,
                    targetName,
                    startupTargetName,
                    dnxServices));
            _databaseOperations = new LazyRef<DatabaseOperations>(
                () => new DatabaseOperations(
                    loggerProvider,
                    targetName,
                    startupTargetName,
                    projectDir,
                    rootNamespace,
                    dnxServices));
            _migrationsOperations = new LazyRef<MigrationsOperations>(
                () => new MigrationsOperations(
                    loggerProvider,
                    targetName,
                    startupTargetName,
                    projectDir,
                    rootNamespace,
                    dnxServices));
        }
Exemple #2
0
            public Executor(string targetProject, string environment, bool verbose)
            {
                var appEnv = PlatformServices.Default.Application;
                var libraryManager = PlatformServices.Default.LibraryManager;

                var loggerProvider = new LoggerProvider(name => new ConsoleCommandLogger(name, verbose, _ansiConsole));
                _logger = new LazyRef<ILogger>(() => loggerProvider.CreateCommandsLogger());

                var targetName = !string.IsNullOrEmpty(targetProject)
                    ? targetProject
                    : appEnv.ApplicationName;
                var startupTargetName = appEnv.ApplicationName;
                var targetLibrary = libraryManager.GetLibrary(targetName);
                var projectDir = Path.GetDirectoryName(targetLibrary.Path);
                var rootNamespace = targetLibrary.Name;

                _contextOperations = new LazyRef<DbContextOperations>(
                    () => new DbContextOperations(
                        loggerProvider,
                        targetName,
                        startupTargetName,
                        environment));
                _databaseOperations = new LazyRef<DatabaseOperations>(
                    () => new DatabaseOperations(
                        loggerProvider,
                        targetName,
                        startupTargetName,
                        environment,
                        projectDir,
                        rootNamespace));
                _migrationsOperations = new LazyRef<MigrationsOperations>(
                    () => new MigrationsOperations(
                        loggerProvider,
                        targetName,
                        startupTargetName,
                        environment,
                        projectDir,
                        rootNamespace));
            }