Ejemplo n.º 1
0
        private void Initialize(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            bundleStream  = StreamUtils.CreateInputStreamOnFile(this.FilePath);
            IAppxBundleFactory bundleFactory = (IAppxBundleFactory) new AppxBundleFactory();

            this.AppxBundleReader = bundleFactory.CreateBundleReader(bundleStream);

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

            this.manifestReader = this.AppxBundleReader.GetManifest();
            this.ManifestStream = this.manifestReader.GetStream();
            IAppxManifestPackageId packageId = this.manifestReader.GetPackageId();

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

            this.PopulateCommonFields();

            this.PopulateChildAppxPackages();
            this.PopulateOptionalAppxPackagesAndBundles();
        }
Ejemplo n.º 2
0
        private void Initialize(IRandomAccessStream randomAccessStream)
        {
            if (randomAccessStream == null)
            {
                throw new ArgumentNullException("file is null");
            }

            //IStream bundleStream = StreamUtils.CreateInputStreamOnFile(this.FilePath);
            Guid               guid          = new Guid("0000000c-0000-0000-C000-000000000046");
            IStream            bundleStream  = StreamUtils.CreateStreamOverRandomAccessStream(randomAccessStream, ref guid);
            IAppxBundleFactory bundleFactory = (IAppxBundleFactory) new AppxBundleFactory();

            this.AppxBundleReader = bundleFactory.CreateBundleReader(bundleStream);

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

            this.manifestReader = this.AppxBundleReader.GetManifest();
            this.ManifestStream = this.manifestReader.GetStream();
            IAppxManifestPackageId packageId = this.manifestReader.GetPackageId();

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

            this.PopulateCommonFields();

            this.PopulateChildAppxPackages();
            this.PopulateOptionalAppxPackagesAndBundles();
        }