Exemple #1
0
        public UWPApplication(IAppxManifestApplication manifestApp, UWP package)
        {
            if (manifestApp == null)
            {
                throw new ArgumentNullException(nameof(manifestApp));
            }

            var hr = manifestApp.GetAppUserModelId(out var tmpUserModelId);

            UserModelId = AppxPackageHelper.CheckHRAndReturnOrThrow(hr, tmpUserModelId);

            hr = manifestApp.GetAppUserModelId(out var tmpUniqueIdentifier);
            UniqueIdentifier = AppxPackageHelper.CheckHRAndReturnOrThrow(hr, tmpUniqueIdentifier);

            hr          = manifestApp.GetStringValue("DisplayName", out var tmpDisplayName);
            DisplayName = AppxPackageHelper.CheckHRAndReturnOrThrow(hr, tmpDisplayName);

            hr          = manifestApp.GetStringValue("Description", out var tmpDescription);
            Description = AppxPackageHelper.CheckHRAndReturnOrThrow(hr, tmpDescription);

            hr = manifestApp.GetStringValue("BackgroundColor", out var tmpBackgroundColor);
            BackgroundColor = AppxPackageHelper.CheckHRAndReturnOrThrow(hr, tmpBackgroundColor);

            hr         = manifestApp.GetStringValue("EntryPoint", out var tmpEntryPoint);
            EntryPoint = AppxPackageHelper.CheckHRAndReturnOrThrow(hr, tmpEntryPoint);

            Package = package ?? throw new ArgumentNullException(nameof(package));

            DisplayName = ResourceFromPri(package.FullName, DisplayName);
            Description = ResourceFromPri(package.FullName, Description);
            logoUri     = LogoUriFromManifest(manifestApp);

            Enabled        = true;
            CanRunElevated = IfApplicationcanRunElevated();
        }
Exemple #2
0
 internal string LogoUriFromManifest(IAppxManifestApplication app)
 {
     if (_logoKeyFromVersion.TryGetValue(Package.Version, out var key))
     {
         var hr = app.GetStringValue(key, out var logoUriFromApp);
         _ = AppxPackageHelper.CheckHRAndReturnOrThrow(hr, logoUriFromApp);
         return(logoUriFromApp);
     }
     else
     {
         return(string.Empty);
     }
 }
Exemple #3
0
        internal string LogoUriFromManifest(IAppxManifestApplication app)
        {
            var logoKeyFromVersion = new Dictionary <PackageVersion, string>
            {
                { PackageVersion.Windows10, "Square44x44Logo" },
                { PackageVersion.Windows81, "Square30x30Logo" },
                { PackageVersion.Windows8, "SmallLogo" },
            };

            if (logoKeyFromVersion.ContainsKey(Package.Version))
            {
                var key = logoKeyFromVersion[Package.Version];
                var hr  = app.GetStringValue(key, out var logoUri);
                _ = AppxPackageHelper.CheckHRAndReturnOrThrow(hr, logoUri);
                return(logoUri);
            }
            else
            {
                return(string.Empty);
            }
        }