Esempio n. 1
0
        private IAppxFile GetManifestInfoFromPackage(IAppxFactory appxFactory, IAppxPackageReader packageReader)
        {
            var appxFile = packageReader.GetFootprintFile(APPX_FOOTPRINT_FILE_TYPE.MANIFEST);
            IAppxManifestReader manifestReader;

            appxFactory.CreateManifestReader(appxFile.GetStream(), out manifestReader);
            GetManifestInfo(manifestReader);
            return(appxFile);
        }
Esempio n. 2
0
        /// <summary>
        /// Initializes this instance of the AppxMetadata class from an msix stream.
        /// </summary>
        /// <param name="packageStream">the msix package stream.</param>
        private void Initialize(IStream packageStream)
        {
            IAppxFactory packageFactory = (IAppxFactory) new AppxFactory();

            this.AppxReader = packageFactory.CreatePackageReader(packageStream);

            this.BlockmapStream = this.AppxReader.GetBlockMap().GetStream();

            IAppxManifestReader appxManifestReader = this.AppxReader.GetManifest();

            this.ManifestStream = appxManifestReader.GetStream();
            IAppxManifestPackageId packageId = appxManifestReader.GetPackageId();

            this.PackageName       = packageId.GetName();
            this.PackageFamilyName = packageId.GetPackageFamilyName();
            this.PackageFullName   = packageId.GetPackageFullName();
            this.Publisher         = packageId.GetPublisher();
            this.Version           = new VersionInfo(packageId.GetVersion());

            IAppxManifestProperties packageProperties = appxManifestReader.GetProperties();
            string displayName;

            packageProperties.GetStringValue("DisplayName", out displayName);
            this.DisplayName = displayName;

            string publisherDisplayName;

            packageProperties.GetStringValue("PublisherDisplayName", out publisherDisplayName);
            this.PublisherDisplayName = publisherDisplayName;

            // Get the min versions
            IAppxManifestReader3 appxManifestReader3 = (IAppxManifestReader3)appxManifestReader;
            IAppxManifestTargetDeviceFamiliesEnumerator targetDeviceFamiliesEnumerator = appxManifestReader3.GetTargetDeviceFamilies();

            while (targetDeviceFamiliesEnumerator.GetHasCurrent())
            {
                IAppxManifestTargetDeviceFamily targetDeviceFamily = targetDeviceFamiliesEnumerator.GetCurrent();
                this.TargetDeviceFamiliesMinVersions.Add(
                    targetDeviceFamily.GetName(),
                    new VersionInfo(targetDeviceFamily.GetMinVersion()));

                targetDeviceFamiliesEnumerator.MoveNext();
            }

            this.MinOSVersion = this.TargetDeviceFamiliesMinVersions.OrderBy(t => t.Value).FirstOrDefault().Value;

            this.PopulateCommonFields();
        }
Esempio n. 3
0
        /// <summary>
        /// Gets a package reader for the file, properly handling for encrypted packages.
        /// </summary>
        /// <param name="packagePath">The path to the package file.</param>
        /// <param name="isEncrypted">True if the package is encrypted; false if not.</param>
        /// <returns>A package reader for the file.</returns>
        public static IAppxPackageReader GetPackageReader(string packagePath, bool isEncrypted = false)
        {
            IAppxPackageReader result = null;

            if (isEncrypted)
            {
                IAppxEncryptionFactory factory = (IAppxEncryptionFactory) new AppxEncryptionFactory();
                result = factory.CreateEncryptedPackageReader(StreamUtils.CreateInputStreamOnFile(packagePath), System.IntPtr.Zero);
            }
            else
            {
                IAppxFactory factory = (IAppxFactory) new AppxFactory();
                result = factory.CreatePackageReader(StreamUtils.CreateInputStreamOnFile(packagePath));
            }

            return(result);
        }
Esempio n. 4
0
 private IAppxFile GetManifestInfoFromPackage(IAppxFactory appxFactory, IAppxPackageReader packageReader)
 {
     var appxFile = packageReader.GetFootprintFile(APPX_FOOTPRINT_FILE_TYPE.MANIFEST);
     IAppxManifestReader manifestReader;
     appxFactory.CreateManifestReader(appxFile.GetStream(), out manifestReader);
     GetManifestInfo(manifestReader);
     return appxFile;
 }