2020-08-13 02:46:11 +08:00
|
|
|
|
// Copyright (c) Microsoft Corporation
|
|
|
|
|
// The Microsoft Corporation licenses this file to you under the MIT license.
|
|
|
|
|
// See the LICENSE file in the project root for more information.
|
|
|
|
|
|
2020-07-11 04:43:02 +08:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Security.Principal;
|
|
|
|
|
using Windows.Management.Deployment;
|
|
|
|
|
using Package = Windows.ApplicationModel.Package;
|
|
|
|
|
|
|
|
|
|
namespace Microsoft.Plugin.Program.Programs
|
|
|
|
|
{
|
|
|
|
|
public class PackageManagerWrapper : IPackageManager
|
|
|
|
|
{
|
|
|
|
|
readonly PackageManager packageManager;
|
|
|
|
|
|
|
|
|
|
public PackageManagerWrapper()
|
|
|
|
|
{
|
|
|
|
|
packageManager = new PackageManager();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public IEnumerable<IPackage> FindPackagesForCurrentUser()
|
|
|
|
|
{
|
|
|
|
|
List<PackageWrapper> packages = new List<PackageWrapper>();
|
|
|
|
|
var user = WindowsIdentity.GetCurrent().User;
|
|
|
|
|
|
|
|
|
|
if (user != null)
|
|
|
|
|
{
|
|
|
|
|
var id = user.Value;
|
|
|
|
|
var m = this.packageManager.FindPackagesForUser(id);
|
|
|
|
|
foreach (Package p in m)
|
|
|
|
|
{
|
|
|
|
|
packages.Add(PackageWrapper.GetWrapperFromPackage(p));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return packages;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|