winget-cli

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

ConfigurationUnitAndModule.cs (2162B)


      1 // -----------------------------------------------------------------------------
      2 // <copyright file="ConfigurationUnitAndModule.cs" company="Microsoft Corporation">
      3 //     Copyright (c) Microsoft Corporation. Licensed under the MIT License.
      4 // </copyright>
      5 // -----------------------------------------------------------------------------
      6 
      7 namespace Microsoft.Management.Configuration.Processor.PowerShell.Helpers
      8 {
      9     using System;
     10     using Microsoft.Management.Configuration;
     11     using Microsoft.Management.Configuration.Processor.Constants;
     12     using Microsoft.Management.Configuration.Processor.Helpers;
     13     using Microsoft.PowerShell.Commands;
     14 
     15     /// <summary>
     16     /// Contains information about the unit and the DSC resource that applies to it.
     17     /// </summary>
     18     internal class ConfigurationUnitAndModule : ConfigurationUnitInternal
     19     {
     20         /// <summary>
     21         /// Initializes a new instance of the <see cref="ConfigurationUnitAndModule"/> class.
     22         /// </summary>
     23         /// <param name="unit">Configuration unit.</param>
     24         /// <param name="configurationFilePath">The configuration file path.</param>
     25         public ConfigurationUnitAndModule(ConfigurationUnit unit, string? configurationFilePath)
     26             : base(unit, configurationFilePath)
     27         {
     28             string? moduleName = this.GetDirective<string>(DirectiveConstants.Module);
     29             if (string.IsNullOrEmpty(moduleName))
     30             {
     31                 this.Module = null;
     32             }
     33             else
     34             {
     35                 this.Module = PowerShellHelpers.CreateModuleSpecification(
     36                     moduleName,
     37                     this.GetDirective<string>(DirectiveConstants.Version),
     38                     this.GetDirective<string>(DirectiveConstants.MinVersion),
     39                     this.GetDirective<string>(DirectiveConstants.MaxVersion),
     40                     this.GetDirective<string>(DirectiveConstants.ModuleGuid));
     41             }
     42         }
     43 
     44         /// <summary>
     45         /// Gets the module specification.
     46         /// </summary>
     47         public ModuleSpecification? Module { get; }
     48     }
     49 }