public AppxMetadata()

in AppInstallerFileBuilder/AppInstallerFileBuilderLib/AppxPackaging/AppxMetadata.cs [80:133]


        public AppxMetadata(string filePath)
        {
            if (string.IsNullOrEmpty(filePath))
            {
                throw new ArgumentNullException("filePath");
            }

            if (!File.Exists(filePath))
            {
                throw new FileNotFoundException(string.Format("{0} not found", filePath));
            }

            this.FilePath = filePath;
            IStream packageStream = StreamUtils.CreateInputStreamOnFile(this.FilePath);
            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();
        }