Esempio n. 1
0
 public void Configure(DbAdvancedOptions options)
 {
     if (!HelpPipeline.CommandAliases.Contains(options.Command))
     {
         GetConnectionFromDatabaseName(options);
     }
 }
Esempio n. 2
0
        public CommandPipelineContext Apply(string command,
                                            DbAdvancedOptions options = null)
        {
            var pipelineFactory = _kernel
                                  .ResolveAll <IPipelineFactory <CommandPipelineContext> >()
                                  .FirstOrDefault(f => f.Aliases.Contains(command));

            if (pipelineFactory == null)
            {
                return(null);
            }

            var context = new CommandPipelineContext
            {
                Options = options ?? _kernel.Resolve <DbAdvancedOptions>()
            };

            var pipeline = pipelineFactory.Create();

            if (pipeline == null)
            {
                return(null);
            }
            pipelineFactory.Execute(pipeline, context);

            return(context);
        }
Esempio n. 3
0
 private void InspectForInteractiveSession(DbAdvancedOptions options)
 {
     if (options.Wait)
     {
         Console.WriteLine("Press any key to exit...");
         Console.ReadKey();
     }
 }
Esempio n. 4
0
 public DatabaseConnectorFactory(ILogger logger,
                                 IDatabaseConnectorConfiguration configuration,
                                 DbAdvancedOptions options)
 {
     this._logger        = logger;
     this._configuration = configuration;
     _options            = options;
 }
Esempio n. 5
0
        private void ExitRunnerWithFailure(DbAdvancedOptions options,
                                           Exception exception = null)
        {
            if (exception != null)
            {
                _container.Resolve <ILogger>().Error(exception.Message, exception);
            }

            InspectForInteractiveSession(options);
            Environment.Exit(-1);
        }
Esempio n. 6
0
        private DbAdvancedOptions InitializeOptionsFromCommandLineArguments(string[] args)
        {
            var options = new DbAdvancedOptions(_container.Resolve <ILogger>());

            options.Configure(args);

            _container.Register(Component
                                .For <DbAdvancedOptions>()
                                .Instance(options));

            return(options);
        }
Esempio n. 7
0
        private void GetConnectionFromDatabaseName(DbAdvancedOptions options)
        {
            if (string.IsNullOrEmpty(options.ConnectionString) &
                string.IsNullOrEmpty(options.Database))
            {
                throw new ArgumentException(
                          "The command line arguement for specifying the target database connection was not supplied");
            }

            if (string.IsNullOrEmpty(options.Database) & !string.IsNullOrEmpty(options.ConnectionString))
            {
                ConnectionString = options.ConnectionString;
                return;
            }

            if (!string.IsNullOrEmpty(options.Database) & string.IsNullOrEmpty(options.ConnectionString))
            {
                try
                {
                    ConnectionString = ConfigurationManager.ConnectionStrings[options.Database].ConnectionString;
                }
                catch
                {
                    throw new ArgumentException(
                              string.Format(
                                  "The connection setting for database via name '{0}' was not specified in the configuration settings file. ",
                                  options.Database));
                }

                if (string.IsNullOrEmpty(ConnectionString))
                {
                    throw new ArgumentException(
                              string.Format(
                                  "The database connection string was not supplied for connection setting via name '{0}' in the configuration settings file. ",
                                  options.Database));
                }
            }
        }
Esempio n. 8
0
 public CommandPipelineContext Apply(DbAdvancedOptions options)
 {
     return(Apply(options.Command, options));
 }
Esempio n. 9
0
 private void ExitRunnerWithSuccess(DbAdvancedOptions options)
 {
     InspectForInteractiveSession(options);
     Environment.Exit(0);
 }
Esempio n. 10
0
 private void RunDesiredCommand(
     DbAdvancedOptions options,
     CommandPipelineFactoryConnector connector)
 {
     connector.Apply(options);
 }
Esempio n. 11
0
 public DatabaseConnectorConfiguration(DbAdvancedOptions options)
 {
     _options = options;
     Configure(_options);
 }