/ src / modules / launcher / Plugins / Microsoft.Plugin.Program / Programs / PackageCatalogWrapper.cs
PackageCatalogWrapper.cs
 1  // Copyright (c) Microsoft Corporation
 2  // The Microsoft Corporation licenses this file to you under the MIT license.
 3  // See the LICENSE file in the project root for more information.
 4  
 5  using Windows.ApplicationModel;
 6  using Windows.Foundation;
 7  
 8  namespace Microsoft.Plugin.Program.Programs
 9  {
10      /// <summary>
11      /// This is a simple wrapper class around the PackageCatalog to facilitate unit testing.
12      /// </summary>
13      internal class PackageCatalogWrapper : IPackageCatalog
14      {
15          private PackageCatalog _packageCatalog;
16  
17          public PackageCatalogWrapper()
18          {
19              // Opens the catalog of packages that is available for the current user.
20              _packageCatalog = PackageCatalog.OpenForCurrentUser();
21          }
22  
23          // Summary: Indicates that an app package is installing.
24          public event TypedEventHandler<PackageCatalog, PackageInstallingEventArgs> PackageInstalling
25          {
26              add
27              {
28                  _packageCatalog.PackageInstalling += value;
29              }
30  
31              remove
32              {
33                  _packageCatalog.PackageInstalling -= value;
34              }
35          }
36  
37          // Summary: Indicates that an app package is uninstalling.
38          public event TypedEventHandler<PackageCatalog, PackageUninstallingEventArgs> PackageUninstalling
39          {
40              add
41              {
42                  _packageCatalog.PackageUninstalling += value;
43              }
44  
45              remove
46              {
47                  _packageCatalog.PackageUninstalling -= value;
48              }
49          }
50  
51          // Summary: Indicates that an app package is updating.
52          public event TypedEventHandler<PackageCatalog, PackageUpdatingEventArgs> PackageUpdating
53          {
54              add
55              {
56                  _packageCatalog.PackageUpdating += value;
57              }
58  
59              remove
60              {
61                  _packageCatalog.PackageUpdating -= value;
62              }
63          }
64      }
65  }