Ejemplo n.º 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="AuthorsPropertyUpgradeStep"/> class.
        /// An upgrade step's constructor should have an ILogger parameter along with parameters for any other
        /// services that need resolved from the dependency injection container. In extensions, AggregateExtension
        /// is a useful service for providing access to extensions' configuration (as read from extension manifests).
        /// </summary>
        /// <param name="logger">Used for logging diagnostic messages. Must be passed to the upgrade step's base class ctor.</param>
        /// <param name="aggregateExtension">A useful service that provides access to extensions' configuration settings.</param>
        public AuthorsPropertyUpgradeStep(AggregateExtension aggregateExtension, ILogger <AuthorsPropertyUpgradeStep> logger)
            : base(logger)
        {
            _logger = logger ?? throw new ArgumentNullException(nameof(logger));
            if (aggregateExtension is null)
            {
                throw new ArgumentNullException(nameof(aggregateExtension));
            }

            // The AggregateExtension type can be used to get files and configuration settings from extensions.
            _options = aggregateExtension.GetOptions <AuthorsPropertyOptions>(AuthorsPropertySectionName);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="FindReplaceUpgradeStep"/> class.
        /// An upgrade step's constructor should have an ILogger parameter along with parameters for any other
        /// services that need resolved from the dependency injection container. In extensions, AggregateExtension
        /// is a useful service for providing access to extensions' configuration (as read from extension manifests).
        /// </summary>
        /// <param name="logger">Used for logging diagnostic messages. Must be passed to the upgrade step's base class ctor.</param>
        /// <param name="aggregateExtension">A useful service that provides access to extensions' configuration settings.</param>
        public FindReplaceUpgradeStep(AggregateExtension aggregateExtension, ILogger <FindReplaceUpgradeStep> logger)
            : base(logger)
        {
            if (aggregateExtension is null)
            {
                throw new ArgumentNullException(nameof(aggregateExtension));
            }

            // Reading configuration from AggregateExtension allows us to read configuration both from this extension's
            // manifest as well as from other extensions' manifests which may wish to further refine the behavior of this one.
            StringsToReplace = aggregateExtension.GetOptions <FindReplaceOptions>(FindReplaceOptionsSectionName)?.Replacements
                               ?? throw new InvalidOperationException("No replacement strings configured");
        }
 public PackageMapProvider(AggregateExtension extensions, ILogger <PackageMapProvider> logger)
 {
     _extensions = extensions ?? throw new ArgumentNullException(nameof(extensions));
     _logger     = logger ?? throw new ArgumentNullException(nameof(logger));
 }