/
githubmirror
/
PowerToys
Обзор
Документация
Войти
/
githubmirror
/
PowerToys
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
src/modules/launcher/Plugins/Microsoft.Plugin.Program/Programs/PackagemanagerWrapper.cs
49 строк
1 KB
Jeremy Sinclair
[Analyzers] Resolve StyleCop issues: SA1516 and SA1616 (#34853)
16 сен 2024, 23:09
Не верифицирован
16 сен 2024, 23:09
37f2154
Код
Авторство
О чём код?
// 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. using System; using System.Collections.Generic; using System.Linq; using System.Security.Principal; using Windows.Management.Deployment; using Wox.Plugin.Logger; using Package = Windows.ApplicationModel.Package; namespace Microsoft.Plugin.Program.Programs { public class PackageManagerWrapper : IPackageManager { private readonly PackageManager _packageManager; public PackageManagerWrapper() { _packageManager = new PackageManager(); } public IEnumerable<IPackage> FindPackagesForCurrentUser() { var user = WindowsIdentity.GetCurrent().User; return user != null ? _packageManager.FindPackagesForUser(user.Value).Select(TryGetWrapperFromPackage).Where(package => package != null) : Enumerable.Empty<IPackage>(); } private static PackageWrapper TryGetWrapperFromPackage(Package package) { try { return PackageWrapper.GetWrapperFromPackage(package); } catch (Exception e) { Log.Error(e.Message, typeof(PackageManagerWrapper)); } return null; } } }