11using System ;
22using System . Collections . Generic ;
3- using System . Linq ;
4- using System . Text ;
53using System . Threading . Tasks ;
64
75using log4net ;
86
97using ITHit . FileSystem . Windows ;
10- using ITHit . FileSystem . Windows . ShellExtension ;
118using ITHit . FileSystem . Windows . Package ;
129
1310
@@ -22,6 +19,8 @@ namespace ITHit.FileSystem.Samples.Common.Windows
2219 /// </remarks>
2320 public class SparsePackageRegistrar : Registrar
2421 {
22+ private static Version minimalSupportedVersion = new Version ( 10 , 0 , 19043 ) ;
23+
2524 /// <summary>
2625 /// Creates instance of this class.
2726 /// </summary>
@@ -46,7 +45,7 @@ public SparsePackageRegistrar(
4645 /// Registers sparse package if needed. In development mode also registers development certificate.
4746 /// </summary>
4847 /// <returns>
49- /// True if app has identity and the app can start execution.
48+ /// True if app has identity and the app can start execution.
5049 /// False if the app needs to restart after sparse package registrtatio or if installation failed.
5150 /// </returns>
5251 public async Task < bool > RegisterSparsePackageAsync ( )
@@ -60,6 +59,7 @@ public async Task<bool> RegisterSparsePackageAsync()
6059
6160 if ( ! PackageRegistrar . SparsePackageRegistered ( ) )
6261 {
62+ EnsureOSVersionIsSupported ( ) ;
6363#if DEBUG
6464 /// Registering sparse package requires a valid certificate.
6565 /// In the development mode we use the below call to install the development certificate.
@@ -81,7 +81,7 @@ public async Task<bool> RegisterSparsePackageAsync()
8181 }
8282
8383 /// <summary>
84- /// Unregisters sparse package. In development mode also registers development certificate.
84+ /// Unregisters sparse package. In development mode also unregisters development certificate.
8585 /// </summary>
8686 public async Task UnregisterSparsePackageAsync ( )
8787 {
@@ -179,5 +179,13 @@ private async Task EnsureConflictingPackagesUninstalled()
179179 }
180180 }
181181#endif
182+
183+ private void EnsureOSVersionIsSupported ( )
184+ {
185+ if ( minimalSupportedVersion . CompareTo ( Environment . OSVersion . Version ) == 1 )
186+ {
187+ throw new NotSupportedException ( $ "Minimal Windows version with sparse package support is: { minimalSupportedVersion } . Please, update your Windows version.") ;
188+ }
189+ }
182190 }
183191}
0 commit comments