@@ -40,6 +40,9 @@ public class WinGetPackageManager : WinGetInfo
4040 private const string _pinRemoveInstalledCmd = "pin remove \" {0}\" --installed" ;
4141 private const string _pinResetCmd = "pin reset --force" ;
4242
43+ private readonly Version _downloadMinVersion = new ( 1 , 6 , 0 ) ;
44+ private readonly Version _pinMinVersion = new ( 1 , 5 , 0 ) ;
45+
4346 /// <summary>
4447 /// Initializes a new instance of the <see cref="WGetNET.WinGetPackageManager"/> class.
4548 /// </summary>
@@ -1066,7 +1069,7 @@ public async Task<bool> UpgradeAllPackagesAsync()
10661069 private string AddArgumentByVersion ( string argument )
10671070 {
10681071 // Checking version to determine if "--include-unknown" is necessary.
1069- if ( WinGetVersionIsMatchOrAbove ( 1 , 4 ) )
1072+ if ( CheckWinGetVersion ( new Version ( 1 , 4 , 0 ) ) )
10701073 {
10711074 // Winget version supports new argument, add "--include-unknown" to arguments
10721075 argument += $ " { _includeUnknown } ";
@@ -1448,9 +1451,9 @@ private string HashResultToHash(ProcessResult result)
14481451 /// </exception>
14491452 public bool Download ( string packageId , string directory )
14501453 {
1451- if ( ! WinGetVersionIsMatchOrAbove ( 1 , 6 ) )
1454+ if ( ! CheckWinGetVersion ( _downloadMinVersion ) )
14521455 {
1453- throw new WinGetFeatureNotSupportedException ( "1.6" ) ;
1456+ throw new WinGetFeatureNotSupportedException ( _downloadMinVersion ) ;
14541457 }
14551458
14561459 try
@@ -1570,9 +1573,9 @@ public bool Download(WinGetPackage package, DirectoryInfo directory)
15701573 /// </exception>
15711574 public async Task < bool > DownloadAsync ( string packageId , string directory )
15721575 {
1573- if ( ! WinGetVersionIsMatchOrAbove ( 1 , 6 ) )
1576+ if ( ! CheckWinGetVersion ( _downloadMinVersion ) )
15741577 {
1575- throw new WinGetFeatureNotSupportedException ( "1.6" ) ;
1578+ throw new WinGetFeatureNotSupportedException ( _downloadMinVersion ) ;
15761579 }
15771580
15781581 try
@@ -1692,9 +1695,9 @@ public async Task<bool> DownloadAsync(WinGetPackage package, DirectoryInfo direc
16921695 /// </exception>
16931696 public List < WinGetPinnedPackage > GetPinnedPackages ( )
16941697 {
1695- if ( ! WinGetVersionIsMatchOrAbove ( 1 , 5 ) )
1698+ if ( ! CheckWinGetVersion ( _pinMinVersion ) )
16961699 {
1697- throw new WinGetFeatureNotSupportedException ( "1.5" ) ;
1700+ throw new WinGetFeatureNotSupportedException ( _pinMinVersion ) ;
16981701 }
16991702
17001703 try
@@ -1732,9 +1735,9 @@ public List<WinGetPinnedPackage> GetPinnedPackages()
17321735 /// </exception>
17331736 public async Task < List < WinGetPinnedPackage > > GetPinnedPackagesAsync ( )
17341737 {
1735- if ( ! WinGetVersionIsMatchOrAbove ( 1 , 5 ) )
1738+ if ( ! CheckWinGetVersion ( _pinMinVersion ) )
17361739 {
1737- throw new WinGetFeatureNotSupportedException ( "1.5" ) ;
1740+ throw new WinGetFeatureNotSupportedException ( _pinMinVersion ) ;
17381741 }
17391742
17401743 try
@@ -1776,9 +1779,9 @@ public async Task<List<WinGetPinnedPackage>> GetPinnedPackagesAsync()
17761779 /// </exception>
17771780 public bool PinAdd ( string packageId , bool blocking = false )
17781781 {
1779- if ( ! WinGetVersionIsMatchOrAbove ( 1 , 5 ) )
1782+ if ( ! CheckWinGetVersion ( _pinMinVersion ) )
17801783 {
1781- throw new WinGetFeatureNotSupportedException ( "1.5" ) ;
1784+ throw new WinGetFeatureNotSupportedException ( _pinMinVersion ) ;
17821785 }
17831786
17841787 try
@@ -1828,9 +1831,9 @@ public bool PinAdd(string packageId, bool blocking = false)
18281831 /// </exception>
18291832 public bool PinAdd ( string packageId , string version )
18301833 {
1831- if ( ! WinGetVersionIsMatchOrAbove ( 1 , 5 ) )
1834+ if ( ! CheckWinGetVersion ( _pinMinVersion ) )
18321835 {
1833- throw new WinGetFeatureNotSupportedException ( "1.5" ) ;
1836+ throw new WinGetFeatureNotSupportedException ( _pinMinVersion ) ;
18341837 }
18351838
18361839 try
@@ -1930,9 +1933,9 @@ public bool PinAdd(WinGetPackage package, string version)
19301933 /// </exception>
19311934 public async Task < bool > PinAddAsync ( string packageId , bool blocking = false )
19321935 {
1933- if ( ! WinGetVersionIsMatchOrAbove ( 1 , 5 ) )
1936+ if ( ! CheckWinGetVersion ( _pinMinVersion ) )
19341937 {
1935- throw new WinGetFeatureNotSupportedException ( "1.5" ) ;
1938+ throw new WinGetFeatureNotSupportedException ( _pinMinVersion ) ;
19361939 }
19371940
19381941 try
@@ -1983,9 +1986,9 @@ public async Task<bool> PinAddAsync(string packageId, bool blocking = false)
19831986 /// </exception>
19841987 public async Task < bool > PinAddAsync ( string packageId , string version )
19851988 {
1986- if ( ! WinGetVersionIsMatchOrAbove ( 1 , 5 ) )
1989+ if ( ! CheckWinGetVersion ( _pinMinVersion ) )
19871990 {
1988- throw new WinGetFeatureNotSupportedException ( "1.5" ) ;
1991+ throw new WinGetFeatureNotSupportedException ( _pinMinVersion ) ;
19891992 }
19901993
19911994 try
@@ -2085,9 +2088,9 @@ public async Task<bool> PinAddAsync(WinGetPackage package, string version)
20852088 /// </exception>
20862089 public bool PinAddInstalled ( string packageId , bool blocking = false )
20872090 {
2088- if ( ! WinGetVersionIsMatchOrAbove ( 1 , 5 ) )
2091+ if ( ! CheckWinGetVersion ( _pinMinVersion ) )
20892092 {
2090- throw new WinGetFeatureNotSupportedException ( "1.5" ) ;
2093+ throw new WinGetFeatureNotSupportedException ( _pinMinVersion ) ;
20912094 }
20922095
20932096 try
@@ -2138,9 +2141,9 @@ public bool PinAddInstalled(string packageId, bool blocking = false)
21382141 /// </exception>
21392142 public bool PinAddInstalled ( string packageId , string version )
21402143 {
2141- if ( ! WinGetVersionIsMatchOrAbove ( 1 , 5 ) )
2144+ if ( ! CheckWinGetVersion ( _pinMinVersion ) )
21422145 {
2143- throw new WinGetFeatureNotSupportedException ( "1.5" ) ;
2146+ throw new WinGetFeatureNotSupportedException ( _pinMinVersion ) ;
21442147 }
21452148
21462149 try
@@ -2240,9 +2243,9 @@ public bool PinAddInstalled(WinGetPackage package, string version)
22402243 /// </exception>
22412244 public async Task < bool > PinAddInstalledAsync ( string packageId , bool blocking = false )
22422245 {
2243- if ( ! WinGetVersionIsMatchOrAbove ( 1 , 5 ) )
2246+ if ( ! CheckWinGetVersion ( _pinMinVersion ) )
22442247 {
2245- throw new WinGetFeatureNotSupportedException ( "1.5" ) ;
2248+ throw new WinGetFeatureNotSupportedException ( _pinMinVersion ) ;
22462249 }
22472250
22482251 try
@@ -2293,9 +2296,9 @@ public async Task<bool> PinAddInstalledAsync(string packageId, bool blocking = f
22932296 /// </exception>
22942297 public async Task < bool > PinAddInstalledAsync ( string packageId , string version )
22952298 {
2296- if ( ! WinGetVersionIsMatchOrAbove ( 1 , 5 ) )
2299+ if ( ! CheckWinGetVersion ( _pinMinVersion ) )
22972300 {
2298- throw new WinGetFeatureNotSupportedException ( "1.5" ) ;
2301+ throw new WinGetFeatureNotSupportedException ( _pinMinVersion ) ;
22992302 }
23002303
23012304 try
@@ -2396,9 +2399,9 @@ public async Task<bool> PinAddInstalledAsync(WinGetPackage package, string versi
23962399 /// </exception>
23972400 public bool PinRemove ( string packageId )
23982401 {
2399- if ( ! WinGetVersionIsMatchOrAbove ( 1 , 5 ) )
2402+ if ( ! CheckWinGetVersion ( _pinMinVersion ) )
24002403 {
2401- throw new WinGetFeatureNotSupportedException ( "1.5" ) ;
2404+ throw new WinGetFeatureNotSupportedException ( _pinMinVersion ) ;
24022405 }
24032406
24042407 try
@@ -2466,9 +2469,9 @@ public bool PinRemove(WinGetPackage package)
24662469 /// </exception>
24672470 public async Task < bool > PinRemoveAsync ( string packageId )
24682471 {
2469- if ( ! WinGetVersionIsMatchOrAbove ( 1 , 5 ) )
2472+ if ( ! CheckWinGetVersion ( _pinMinVersion ) )
24702473 {
2471- throw new WinGetFeatureNotSupportedException ( "1.5" ) ;
2474+ throw new WinGetFeatureNotSupportedException ( _pinMinVersion ) ;
24722475 }
24732476
24742477 try
@@ -2535,9 +2538,9 @@ public async Task<bool> PinRemoveAsync(WinGetPackage package)
25352538 /// </exception>
25362539 public bool PinRemoveInstalled ( string packageId )
25372540 {
2538- if ( ! WinGetVersionIsMatchOrAbove ( 1 , 5 ) )
2541+ if ( ! CheckWinGetVersion ( _pinMinVersion ) )
25392542 {
2540- throw new WinGetFeatureNotSupportedException ( "1.5" ) ;
2543+ throw new WinGetFeatureNotSupportedException ( _pinMinVersion ) ;
25412544 }
25422545
25432546 try
@@ -2604,9 +2607,9 @@ public bool PinRemoveInstalled(WinGetPackage package)
26042607 /// </exception>
26052608 public async Task < bool > PinRemoveInstalledAsync ( string packageId )
26062609 {
2607- if ( ! WinGetVersionIsMatchOrAbove ( 1 , 5 ) )
2610+ if ( ! CheckWinGetVersion ( _pinMinVersion ) )
26082611 {
2609- throw new WinGetFeatureNotSupportedException ( "1.5" ) ;
2612+ throw new WinGetFeatureNotSupportedException ( _pinMinVersion ) ;
26102613 }
26112614
26122615 try
@@ -2677,9 +2680,9 @@ public async Task<bool> PinRemoveInstalledAsync(WinGetPackage package)
26772680 /// </exception>
26782681 public bool ResetPins ( )
26792682 {
2680- if ( ! WinGetVersionIsMatchOrAbove ( 1 , 5 ) )
2683+ if ( ! CheckWinGetVersion ( _pinMinVersion ) )
26812684 {
2682- throw new WinGetFeatureNotSupportedException ( "1.5" ) ;
2685+ throw new WinGetFeatureNotSupportedException ( _pinMinVersion ) ;
26832686 }
26842687
26852688 try
@@ -2720,9 +2723,9 @@ public bool ResetPins()
27202723 /// </exception>
27212724 public async Task < bool > ResetPinsAsync ( )
27222725 {
2723- if ( ! WinGetVersionIsMatchOrAbove ( 1 , 5 ) )
2726+ if ( ! CheckWinGetVersion ( _pinMinVersion ) )
27242727 {
2725- throw new WinGetFeatureNotSupportedException ( "1.5" ) ;
2728+ throw new WinGetFeatureNotSupportedException ( _pinMinVersion ) ;
27262729 }
27272730
27282731 try
0 commit comments