Пример #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="VersioningCheckCommand" /> class.
 /// </summary>
 /// <param name="action">The action running with this command.</param>
 /// <param name="commandSettings">The command settings associated with this command.</param>
 /// <param name="loggerFactory">The logger factory.</param>
 /// <exception cref="ArgumentNullException">loggerFactory</exception>
 public VersioningCheckCommand(IAction action, Settings.Command commandSettings, ILoggerFactory loggerFactory)
     : base(action, commandSettings, loggerFactory)
 {
     if (loggerFactory == null)
     {
         throw new ArgumentNullException(nameof(loggerFactory));
     }
     Logger = loggerFactory.CreateLogger <VersioningCheckCommand>();
 }
Пример #2
0
        /// <summary>
        /// Creates the specified action.
        /// </summary>
        /// <param name="action">The action associated with this Command.</param>
        /// <param name="commandSettings">The settings associated with this Command.</param>
        /// <returns>Returns an instance of the SyncAction which is an instance of IAction.</returns>
        /// <exception cref="ArgumentNullException">actionSettings
        /// or
        /// settings
        /// or
        /// serviceProvider</exception>
        /// <exception cref="InvalidOperationException">actionSettings
        /// or
        /// settings
        /// or
        /// serviceProvider</exception>
        /// <exception cref="NotImplementedException"></exception>
        public override ICommand Create(IAction action, Settings.Command commandSettings)
        {
            if (commandSettings == null)
            {
                throw new ArgumentNullException(nameof(commandSettings));
            }
            Debug.Assert(commandSettings.Type.Equals(Type, StringComparison.CurrentCultureIgnoreCase));
            var command = ActivatorUtilities.CreateInstance <VersioningCheckCommand>(ServiceProvider, action,
                                                                                     commandSettings.CloneAndMergeSettings(ApplicationSettings.SettingsGroups.Find(commandSettings.SettingsGroup)));

            return(command);
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="NugetContainsSupportFilesCommand" /> class.
 /// </summary>
 /// <param name="action">The action running with this command.</param>
 /// <param name="commandSettings">The command settings associated with this command.</param>
 /// <param name="loggerFactory">The logger factory.</param>
 /// <exception cref="ArgumentNullException">loggerFactory</exception>
 public NugetContainsSupportFilesCommand(
     IAction action,
     Settings.Command commandSettings,
     ILoggerFactory loggerFactory)
     : base(action, commandSettings, loggerFactory)
 {
     if (loggerFactory == null)
     {
         throw new ArgumentNullException(nameof(loggerFactory));
     }
     Logger = loggerFactory.CreateLogger <NugetContainsSupportFilesCommand>();
 }
Пример #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ApplicationIs64BitCommand" /> class.
 /// </summary>
 /// <param name="action">The action running with this command.</param>
 /// <param name="commandSettings">The command settings associated with this command.</param>
 /// <param name="loggerFactory">The logger factory.</param>
 /// <exception cref="ArgumentNullException">loggerFactory</exception>
 public ApplicationIs64BitCommand(
     IAction action,
     Settings.Command commandSettings,
     ILoggerFactory loggerFactory)
     : base(action, commandSettings, loggerFactory)
 {
     if (loggerFactory == null)
     {
         throw new ArgumentNullException(nameof(loggerFactory));
     }
     Logger = loggerFactory.CreateLogger <ApplicationIs64BitCommand>();
 }
Пример #5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CatalogCommand" /> class.
        /// </summary>
        /// <param name="action">The action running with this command.</param>
        /// <param name="commandSettings">The command settings associated with this command.</param>
        /// <param name="loggerFactory">The logger factory.</param>
        /// <param name="configuration">The configuration service</param>
        /// <exception cref="ArgumentNullException">loggerFactory</exception>
        public CatalogCommand(
            IAction action,
            Settings.Command commandSettings,
            ILoggerFactory loggerFactory,
            IConfiguration configuration)
            : base(action, commandSettings, loggerFactory)
        {
            if (loggerFactory == null)
            {
                throw new ArgumentNullException(nameof(loggerFactory));
            }

            Logger = loggerFactory.CreateLogger <CatalogCommand>();

            var connectionStringName = commandSettings.Settings.ConnectionStringName();

            if (connectionStringName == null)
            {
                connectionStringName = "PackageModel";
                Logger.LogInformation("No connection string name configured for Catalog command. Using \"PackageModel\".");
            }

            var connectionString = configuration.GetConnectionString(connectionStringName);

            if (string.IsNullOrEmpty(connectionString))
            {
                throw new InvalidOperationException($"No connection string found with the name \"{commandSettings.Settings.ConnectionStringName()}\" ");
            }

            dbContext = new PackageModelContext(connectionString);

            if (!string.IsNullOrEmpty(commandSettings.Settings.NormalizeRegEx()))
            {
                normalizeNameRegex = new Regex(commandSettings.Settings.NormalizeRegEx());
            }

            if (action.ActionSettings.IncludePrerelease)
            {
                Logger.LogWarning($"The {nameof(CatalogCommand)} does not support pre-release versions.");
            }
        }