winget-cli

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

PowerShellConfigurationUnitProcessor.cs (2844B)


      1 // -----------------------------------------------------------------------------
      2 // <copyright file="PowerShellConfigurationUnitProcessor.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.Unit
      8 {
      9     using Microsoft.Management.Configuration;
     10     using Microsoft.Management.Configuration.Processor.PowerShell.Helpers;
     11     using Microsoft.Management.Configuration.Processor.PowerShell.ProcessorEnvironments;
     12     using Microsoft.Management.Configuration.Processor.Unit;
     13     using Windows.Foundation.Collections;
     14 
     15     /// <summary>
     16     /// Provides access to a specific configuration unit within the runtime.
     17     /// </summary>
     18     internal sealed partial class PowerShellConfigurationUnitProcessor : ConfigurationUnitProcessorBase, IConfigurationUnitProcessor
     19     {
     20         private readonly IProcessorEnvironment processorEnvironment;
     21         private readonly ConfigurationUnitAndResource unitResource;
     22 
     23         /// <summary>
     24         /// Initializes a new instance of the <see cref="PowerShellConfigurationUnitProcessor"/> class.
     25         /// </summary>
     26         /// <param name="processorEnvironment">Processor environment.</param>
     27         /// <param name="unitResource">UnitResource.</param>
     28         /// <param name="isLimitMode">Whether it is under limit mode.</param>
     29         internal PowerShellConfigurationUnitProcessor(IProcessorEnvironment processorEnvironment, ConfigurationUnitAndResource unitResource, bool isLimitMode = false)
     30             : base(unitResource.UnitInternal, isLimitMode)
     31         {
     32             this.processorEnvironment = processorEnvironment;
     33             this.unitResource = unitResource;
     34         }
     35 
     36         /// <inheritdoc />
     37         protected override ValueSet GetSettingsInternal()
     38         {
     39             return this.processorEnvironment.InvokeGetResource(
     40                 this.unitResource.GetSettings(),
     41                 this.unitResource.ResourceName,
     42                 this.unitResource.Module);
     43         }
     44 
     45         /// <inheritdoc />
     46         protected override bool TestSettingsInternal()
     47         {
     48             return this.processorEnvironment.InvokeTestResource(
     49                 this.unitResource.GetSettings(),
     50                 this.unitResource.ResourceName,
     51                 this.unitResource.Module);
     52         }
     53 
     54         /// <inheritdoc />
     55         protected override bool ApplySettingsInternal()
     56         {
     57             return this.processorEnvironment.InvokeSetResource(
     58                 this.unitResource.GetSettings(),
     59                 this.unitResource.ResourceName,
     60                 this.unitResource.Module);
     61         }
     62     }
     63 }