PSPackageVersionInfo.cs (3181B)
1 // ----------------------------------------------------------------------------- 2 // <copyright file="PSPackageVersionInfo.cs" company="Microsoft Corporation"> 3 // Copyright (c) Microsoft Corporation. Licensed under the MIT License. 4 // </copyright> 5 // ----------------------------------------------------------------------------- 6 7 namespace Microsoft.WinGet.Client.Engine.PSObjects 8 { 9 using System.Linq; 10 using Microsoft.Management.Deployment; 11 12 /// <summary> 13 /// PackageVersionInfo wrapper object for displaying to PowerShell. 14 /// </summary> 15 public sealed class PSPackageVersionInfo 16 { 17 private PackageVersionInfo packageVersionInfo; 18 19 /// <summary> 20 /// Initializes a new instance of the <see cref="PSPackageVersionInfo"/> class. 21 /// </summary> 22 /// <param name="packageVersionInfo">PackageVersionInfo COM object.</param> 23 internal PSPackageVersionInfo(PackageVersionInfo packageVersionInfo) 24 { 25 this.packageVersionInfo = packageVersionInfo; 26 } 27 28 /// <summary> 29 /// Gets the name of the package version info. 30 /// </summary> 31 public string DisplayName 32 { 33 get 34 { 35 return this.packageVersionInfo.DisplayName; 36 } 37 } 38 39 /// <summary> 40 /// Gets the id of the package version info. 41 /// </summary> 42 public string Id 43 { 44 get 45 { 46 return this.packageVersionInfo.Id; 47 } 48 } 49 50 /// <summary> 51 /// Gets the publisher of the package version info. 52 /// </summary> 53 public string Publisher 54 { 55 get 56 { 57 return this.packageVersionInfo.Publisher; 58 } 59 } 60 61 /// <summary> 62 /// Gets the channel of the package version info. 63 /// </summary> 64 public string Channel 65 { 66 get 67 { 68 return this.packageVersionInfo.Channel; 69 } 70 } 71 72 /// <summary> 73 /// Gets the list of package family names of the package version info. 74 /// </summary> 75 public string[] PackageFamilyNames 76 { 77 get 78 { 79 return this.packageVersionInfo.PackageFamilyNames.ToArray(); 80 } 81 } 82 83 /// <summary> 84 /// Gets the list of product codes of the package version info. 85 /// </summary> 86 public string[] ProductCodes 87 { 88 get 89 { 90 return this.packageVersionInfo.ProductCodes.ToArray(); 91 } 92 } 93 94 /// <summary> 95 /// Compares the version string with the package version info and returns the CompareResult. 96 /// </summary> 97 /// <param name="version">Version string.</param> 98 /// <returns>CompareResult string.</returns> 99 public string CompareToVersion(string version) 100 { 101 return this.packageVersionInfo.CompareToVersion(version).ToString(); 102 } 103 } 104 }