mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-06 03:07:04 +02:00
@@ -37,6 +37,10 @@ namespace Wox.Plugin.Program.Programs
|
||||
|
||||
public int Score { get; set; }
|
||||
|
||||
public UWP()
|
||||
{
|
||||
Apps = new Application[] { };
|
||||
}
|
||||
public UWP(Package package)
|
||||
{
|
||||
Package = package;
|
||||
@@ -118,37 +122,32 @@ namespace Wox.Plugin.Program.Programs
|
||||
}).ToArray();
|
||||
}
|
||||
|
||||
public static List<UWP> All()
|
||||
public static UWP[] All()
|
||||
{
|
||||
var windows10 = new Version(10, 0);
|
||||
var support = Environment.OSVersion.Version.Major >= windows10.Major;
|
||||
if (support)
|
||||
{
|
||||
var packages = CurrentUserPackages();
|
||||
var uwps = new List<UWP>();
|
||||
// todo use parallel linq
|
||||
Parallel.ForEach(packages, p =>
|
||||
var packages = CurrentUserPackages().AsParallel().Select(p =>
|
||||
{
|
||||
try
|
||||
{
|
||||
var u = new UWP(p);
|
||||
if (u.Apps.Length > 0)
|
||||
{
|
||||
uwps.Add(u);
|
||||
}
|
||||
return u;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
// if there are errors, just ignore it and continue
|
||||
var message = $"Can't parse {p.Id.Name}: {e.Message}";
|
||||
Log.Error(message);
|
||||
return new UWP();
|
||||
}
|
||||
});
|
||||
return uwps;
|
||||
}).Where(u => u.Apps.Length > 0);
|
||||
return packages.ToArray();
|
||||
}
|
||||
else
|
||||
{
|
||||
return new List<UWP>();
|
||||
return new UWP[] { };
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user