Ejemplo n.º 1
0
        private void Run_Async(object state)
        {
            try
            {
                IStream packageStream;

                // this function can be called from the bundle reader below or from external
                if (internalPackage)
                {
                    packageStream = stream;
                }
                else
                {
                    packageStream = StreamFactory.CreateFileStream(packagePath, STGM.STGM_READ);
                }

                AppxPackage package = GetAppxPackageFromStream(packageStream);

                if (package.PackageType == AppxPackage.PACKAGE_TYPE.PACKAGE_TYPE_APPX_BUNDLE)
                {
                    List <AppxPackage> mainPackagesFromBundle     = new List <AppxPackage>();
                    List <AppxPackage> resourcePackagesFrombundle = new List <AppxPackage>();
                    foreach (AppxPackage containedPackage in (package as AppxBundlePackage).ContainedPackages)
                    {
                        if (containedPackage.PackageType == AppxPackage.PACKAGE_TYPE.PACKAGE_TYPE_APPX_RESOUCE)
                        {
                            resourcePackagesFrombundle.Add(containedPackage);
                        }

                        else if (containedPackage.PackageType == AppxPackage.PACKAGE_TYPE.PACKAGE_TYPE_APPX_PACKAGE)
                        {
                            mainPackagesFromBundle.Add(containedPackage);
                        }
                    }

                    MainPackages.Add(SelectCorrectMainPackage(mainPackagesFromBundle));
                    ResourcePackages.AddRange(resourcePackagesFrombundle);
                }
                else
                {
                    MainPackages.Add(package);
                }
            }
            catch (System.Runtime.InteropServices.COMException ex)
            {
                errorEncountered = true;
                errorText        = "Input package is corrupted. Error: '" + ex.HResult + "'";
            }
            catch (Exception ex)
            {
                errorEncountered = true;
                errorText        = "Error encoutered. Error: '" + ex.HResult + "'";
            }

            // set the event
            mre.Set();
        }
Ejemplo n.º 2
0
        public static AppxManifest GetManifestFromPath(string path)
        {
            var stream = StreamFactory.CreateFileStream(path, STGM.STGM_READ);
            var type   = GetAppxPackageTypeFromStream(stream);

            if (type == AppxPackage.PACKAGE_TYPE.PACKAGE_TYPE_APPX_BUNDLE)
            {
                return(GetManifestInformationForAppxBundle(stream));
            }
            return(GetManifestInformationForAppxPackage(stream));
        }