set AppxPackageHelper to static

This commit is contained in:
Vic 2022-10-21 18:34:49 +08:00
parent e72810ca2c
commit 02b23756ff
2 changed files with 5 additions and 5 deletions

View file

@ -9,12 +9,13 @@ namespace Flow.Launcher.Plugin.Program.Programs
{
public class AppxPackageHelper
{
private static readonly IAppxFactory appxFactory = (IAppxFactory)new AppxFactory();
// This function returns a list of attributes of applications
public List<IAppxManifestApplication> getAppsFromManifest(IStream stream)
public static List<IAppxManifestApplication> GetAppsFromManifest(IStream stream)
{
List<IAppxManifestApplication> apps = new List<IAppxManifestApplication>();
var appxFactory = new AppxFactory();
var reader = ((IAppxFactory)appxFactory).CreateManifestReader(stream);
var reader = appxFactory.CreateManifestReader(stream);
var manifestApps = reader.GetApplications();
while (manifestApps.GetHasCurrent())
{

View file

@ -53,7 +53,6 @@ namespace Flow.Launcher.Plugin.Program.Programs
private void InitializeAppInfo()
{
AppxPackageHelper _helper = new AppxPackageHelper();
var path = Path.Combine(Location, "AppxManifest.xml");
var namespaces = XmlNamespaces(path);
@ -67,7 +66,7 @@ namespace Flow.Launcher.Plugin.Program.Programs
{
var apps = new List<Application>();
List<AppxPackageHelper.IAppxManifestApplication> _apps = _helper.getAppsFromManifest(stream);
List<AppxPackageHelper.IAppxManifestApplication> _apps = AppxPackageHelper.GetAppsFromManifest(stream);
foreach (var _app in _apps)
{
var app = new Application(_app, this);