forked from microsoft/winget-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
split out module from config unit internal
- Loading branch information
Showing
15 changed files
with
213 additions
and
155 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
...osoft.Management.Configuration.Processor/PowerShell/Helpers/ConfigurationUnitAndModule.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// ----------------------------------------------------------------------------- | ||
// <copyright file="ConfigurationUnitAndModule.cs" company="Microsoft Corporation"> | ||
// Copyright (c) Microsoft Corporation. Licensed under the MIT License. | ||
// </copyright> | ||
// ----------------------------------------------------------------------------- | ||
|
||
namespace Microsoft.Management.Configuration.Processor.PowerShell.Helpers | ||
{ | ||
using System; | ||
using Microsoft.Management.Configuration; | ||
using Microsoft.Management.Configuration.Processor.Constants; | ||
using Microsoft.Management.Configuration.Processor.Helpers; | ||
using Microsoft.PowerShell.Commands; | ||
|
||
/// <summary> | ||
/// Contains information about the unit and the DSC resource that applies to it. | ||
/// </summary> | ||
internal class ConfigurationUnitAndModule : ConfigurationUnitInternal | ||
{ | ||
/// <summary> | ||
/// Initializes a new instance of the <see cref="ConfigurationUnitAndModule"/> class. | ||
/// </summary> | ||
/// <param name="unit">Configuration unit.</param> | ||
/// <param name="configurationFilePath">The configuration file path.</param> | ||
public ConfigurationUnitAndModule(ConfigurationUnit unit, string? configurationFilePath) | ||
: base(unit, configurationFilePath) | ||
{ | ||
string? moduleName = this.GetDirective<string>(DirectiveConstants.Module); | ||
if (string.IsNullOrEmpty(moduleName)) | ||
{ | ||
this.Module = null; | ||
} | ||
else | ||
{ | ||
this.Module = PowerShellHelpers.CreateModuleSpecification( | ||
moduleName, | ||
this.GetDirective<string>(DirectiveConstants.Version), | ||
this.GetDirective<string>(DirectiveConstants.MinVersion), | ||
this.GetDirective<string>(DirectiveConstants.MaxVersion), | ||
this.GetDirective<string>(DirectiveConstants.ModuleGuid)); | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Gets the module specification. | ||
/// </summary> | ||
public ModuleSpecification? Module { get; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
...anagement.Configuration.Processor/PowerShell/Unit/PowerShellConfigurationUnitProcessor.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
// ----------------------------------------------------------------------------- | ||
// <copyright file="PowerShellConfigurationUnitProcessor.cs" company="Microsoft Corporation"> | ||
// Copyright (c) Microsoft Corporation. Licensed under the MIT License. | ||
// </copyright> | ||
// ----------------------------------------------------------------------------- | ||
|
||
namespace Microsoft.Management.Configuration.Processor.PowerShell.Unit | ||
{ | ||
using Microsoft.Management.Configuration; | ||
using Microsoft.Management.Configuration.Processor.PowerShell.Helpers; | ||
using Microsoft.Management.Configuration.Processor.PowerShell.ProcessorEnvironments; | ||
using Microsoft.Management.Configuration.Processor.Unit; | ||
using Windows.Foundation.Collections; | ||
|
||
/// <summary> | ||
/// Provides access to a specific configuration unit within the runtime. | ||
/// </summary> | ||
internal sealed partial class PowerShellConfigurationUnitProcessor : ConfigurationUnitProcessorBase, IConfigurationUnitProcessor | ||
{ | ||
private readonly IProcessorEnvironment processorEnvironment; | ||
private readonly ConfigurationUnitAndResource unitResource; | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="PowerShellConfigurationUnitProcessor"/> class. | ||
/// </summary> | ||
/// <param name="processorEnvironment">Processor environment.</param> | ||
/// <param name="unitResource">UnitResource.</param> | ||
/// <param name="isLimitMode">Whether it is under limit mode.</param> | ||
internal PowerShellConfigurationUnitProcessor(IProcessorEnvironment processorEnvironment, ConfigurationUnitAndResource unitResource, bool isLimitMode = false) | ||
: base(unitResource.UnitInternal, isLimitMode) | ||
{ | ||
this.processorEnvironment = processorEnvironment; | ||
this.unitResource = unitResource; | ||
} | ||
|
||
/// <inheritdoc /> | ||
protected override ValueSet GetSettingsInternal() | ||
{ | ||
return this.processorEnvironment.InvokeGetResource( | ||
this.unitResource.GetSettings(), | ||
this.unitResource.ResourceName, | ||
this.unitResource.Module); | ||
} | ||
|
||
/// <inheritdoc /> | ||
protected override bool TestSettingsInternal() | ||
{ | ||
return this.processorEnvironment.InvokeTestResource( | ||
this.unitResource.GetSettings(), | ||
this.unitResource.ResourceName, | ||
this.unitResource.Module); | ||
} | ||
|
||
/// <inheritdoc /> | ||
protected override bool ApplySettingsInternal() | ||
{ | ||
return this.processorEnvironment.InvokeSetResource( | ||
this.unitResource.GetSettings(), | ||
this.unitResource.ResourceName, | ||
this.unitResource.Module); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.