winget-cli

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

PSValidateConfigurationSetResult.cs (1795B)


      1 // -----------------------------------------------------------------------------
      2 // <copyright file="PSValidateConfigurationSetResult.cs" company="Microsoft Corporation">
      3 //     Copyright (c) Microsoft Corporation. Licensed under the MIT License.
      4 // </copyright>
      5 // -----------------------------------------------------------------------------
      6 
      7 namespace Microsoft.WinGet.Configuration.Engine.PSObjects
      8 {
      9     using System.Collections.Generic;
     10     using Microsoft.Management.Configuration;
     11     using Microsoft.WinGet.Configuration.Engine.Exceptions;
     12 
     13     /// <summary>
     14     /// Wrapper for ApplyConfigurationSetResult for validate.
     15     /// </summary>
     16     public class PSValidateConfigurationSetResult
     17     {
     18         /// <summary>
     19         /// Initializes a new instance of the <see cref="PSValidateConfigurationSetResult"/> class.
     20         /// </summary>
     21         /// <param name="applySetResult">Apply set result.</param>
     22         internal PSValidateConfigurationSetResult(ApplyConfigurationSetResult applySetResult)
     23         {
     24             this.ResultCode = applySetResult.ResultCode?.HResult ?? ErrorCodes.S_OK;
     25 
     26             var unitResults = new List<PSValidateConfigurationUnitResult>();
     27             foreach (var unitResult in applySetResult.UnitResults)
     28             {
     29                 unitResults.Add(new PSValidateConfigurationUnitResult(unitResult));
     30             }
     31 
     32             this.UnitResults = unitResults;
     33         }
     34 
     35         /// <summary>
     36         /// Gets the result code.
     37         /// </summary>
     38         public int ResultCode { get; private init; }
     39 
     40         /// <summary>
     41         /// Gets the results of the units.
     42         /// </summary>
     43         public IReadOnlyList<PSValidateConfigurationUnitResult> UnitResults { get; private init; }
     44     }
     45 }