示例#1
0
        public ApplyCommand(
            ISchemaManager schemaManager,
            ILogger <ApplyCommand> logger)
            : base(CommandNames.Apply, Resources.ApplyCommandDescription)
        {
            AddOption(CommandOptions.ConnectionStringOption());
            AddOption(CommandOptions.ServerOption());
            AddOption(CommandOptions.VersionOption());
            AddOption(CommandOptions.NextOption());
            AddOption(CommandOptions.LatestOption());
            AddOption(CommandOptions.ForceOption());

            Handler = CommandHandler.Create(
                (string connectionString, Uri server, MutuallyExclusiveType type, bool force, CancellationToken token)
                => HandlerAsync(connectionString, server, type, force, token));

            Argument.AddValidator(symbol => RequiredOptionValidator.Validate(symbol, CommandOptions.ConnectionStringOption(), Resources.ConnectionStringRequiredValidation));
            Argument.AddValidator(symbol => RequiredOptionValidator.Validate(symbol, CommandOptions.ServerOption(), Resources.ServerRequiredValidation));
            Argument.AddValidator(symbol => MutuallyExclusiveOptionValidator.Validate(symbol, new List <Option> {
                CommandOptions.VersionOption(), CommandOptions.NextOption(), CommandOptions.LatestOption()
            }, Resources.MutuallyExclusiveValidation));

            EnsureArg.IsNotNull(logger, nameof(logger));
            EnsureArg.IsNotNull(schemaManager, nameof(schemaManager));

            _logger        = logger;
            _schemaManager = schemaManager;
        }
示例#2
0
        public ApplyCommand(
            SqlServerDataStoreConfiguration sqlServerDataStoreConfiguration,
            BaseSchemaRunner baseSchemaRunner,
            ISchemaManagerDataStore schemaManagerDataStore,
            ISchemaClient schemaClient)
            : base(CommandNames.Apply, Resources.ApplyCommandDescription)
        {
            AddOption(CommandOptions.ConnectionStringOption());
            AddOption(CommandOptions.ServerOption());
            AddOption(CommandOptions.VersionOption());
            AddOption(CommandOptions.NextOption());
            AddOption(CommandOptions.LatestOption());
            AddOption(CommandOptions.ForceOption());

            Handler = CommandHandler.Create(
                (string connectionString, Uri server, MutuallyExclusiveType type, bool force, CancellationToken token)
                => HandlerAsync(connectionString, server, type, force, token));

            Argument.AddValidator(symbol => Validators.RequiredOptionValidator.Validate(symbol, CommandOptions.ConnectionStringOption(), Resources.ConnectionStringRequiredValidation));
            Argument.AddValidator(symbol => Validators.RequiredOptionValidator.Validate(symbol, CommandOptions.ServerOption(), Resources.ServerRequiredValidation));
            Argument.AddValidator(symbol => Validators.MutuallyExclusiveOptionValidator.Validate(symbol, new List <Option> {
                CommandOptions.VersionOption(), CommandOptions.NextOption(), CommandOptions.LatestOption()
            }, Resources.MutuallyExclusiveValidation));

            EnsureArg.IsNotNull(sqlServerDataStoreConfiguration);
            EnsureArg.IsNotNull(baseSchemaRunner);
            EnsureArg.IsNotNull(schemaManagerDataStore);
            EnsureArg.IsNotNull(schemaClient);

            _sqlServerDataStoreConfiguration = sqlServerDataStoreConfiguration;
            _baseSchemaRunner       = baseSchemaRunner;
            _schemaManagerDataStore = schemaManagerDataStore;
            _schemaClient           = schemaClient;
        }