PSGetConfigurationDetailsResult.cs (1954B)
1 // ----------------------------------------------------------------------------- 2 // <copyright file="PSGetConfigurationDetailsResult.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; 10 using Microsoft.Management.Configuration; 11 using Microsoft.WinGet.Configuration.Engine.Exceptions; 12 13 /// <summary> 14 /// Result for getting the details of a unit. 15 /// </summary> 16 public class PSGetConfigurationDetailsResult 17 { 18 /// <summary> 19 /// Initializes a new instance of the <see cref="PSGetConfigurationDetailsResult"/> class. 20 /// </summary> 21 /// <param name="result">Get unit details result.</param> 22 internal PSGetConfigurationDetailsResult(GetConfigurationUnitDetailsResult result) 23 { 24 this.Type = result.Unit.Type; 25 this.ResultCode = result.ResultInformation?.ResultCode?.HResult ?? ErrorCodes.S_OK; 26 27 if (result.ResultInformation?.ResultCode != null) 28 { 29 this.ErrorMessage = $"Failed to get unit details for {this.Type} 0x{this.ResultCode:X}" + 30 $"{Environment.NewLine}Description: '{result.ResultInformation.Description}'{Environment.NewLine}Details: '{result.ResultInformation.Details}'"; 31 } 32 } 33 34 /// <summary> 35 /// Gets the unit type. 36 /// </summary> 37 public string Type { get; private init; } 38 39 /// <summary> 40 /// Gets the result code. 41 /// </summary> 42 public int ResultCode { get; private init; } 43 44 /// <summary> 45 /// Gets the error message. 46 /// </summary> 47 public string? ErrorMessage { get; private init; } 48 } 49 }