예제 #1
0
        public static UWPApplication[] All()
        {
            var windows10 = new Version(10, 0);
            var support   = Environment.OSVersion.Version.Major >= windows10.Major;

            if (support)
            {
                var applications = CurrentUserPackages().AsParallel().SelectMany(p =>
                {
                    UWP u;
                    try
                    {
                        u = new UWP(p);
                        u.InitializeAppInfo(p.InstalledLocation);
                    }
                    catch (Exception e)
                    {
                        ProgramLogger.LogException(
                            $"|UWP|All|{p.InstalledLocation}|An unexpected error occurred and "
                            + $"unable to convert Package to UWP for {p.FullName}", e);
                        return(Array.Empty <UWPApplication>());
                    }

                    return(u.Apps);
                }).ToArray();

                var updatedListWithoutDisabledApps = applications
                                                     .Where(t1 => !Main._settings.DisabledProgramSources
                                                            .Any(x => x.UniqueIdentifier == t1.UniqueIdentifier))
                                                     .Select(x => x);

                return(updatedListWithoutDisabledApps.ToArray());
            }
            else
            {
                return(Array.Empty <UWPApplication>());
            }
        }
예제 #2
0
        public static UWPApplication[] All()
        {
            var windows10 = new Version(10, 0);
            var support   = Environment.OSVersion.Version.Major >= windows10.Major;

            if (support)
            {
                var applications = CurrentUserPackages().AsParallel().SelectMany(p =>
                {
                    UWP u;
                    try
                    {
                        u = new UWP(p);
                        u.InitializeAppInfo(p.InstalledLocation);
                    }
                    catch (Exception e)
                    {
                        ProgramLogger.Exception($"Unable to convert Package to UWP for {p.FullName}", e, MethodBase.GetCurrentMethod().DeclaringType, p.InstalledLocation);

                        return(Array.Empty <UWPApplication>());
                    }

                    return(u.Apps);
                });

                var updatedListWithoutDisabledApps = applications
                                                     .Where(t1 => Main.Settings.DisabledProgramSources.All(x => x.UniqueIdentifier != t1.UniqueIdentifier))
                                                     .Select(x => x);

                return(updatedListWithoutDisabledApps.ToArray());
            }
            else
            {
                return(Array.Empty <UWPApplication>());
            }
        }