Ejemplo n.º 1
0
        private IEnumerable <PackageFragmentValidationResult> Initialize()
        {
            if (_isInitialized)
            {
                throw new InvalidOperationException("Initialize() may only be called once");
            }
            _isInitialized = true;

            Exception exception = null;

            try
            {
                _packageInstallerContex = new PackageInstallerContext(new ZipFileSystem(this.ZipFilename), this.PackageInstallDirectory, this.TempDirectory, this.PackageInformation);
            }
            catch (Exception ex)
            {
                exception = ex;
            }
            if (exception != null)
            {
                return new [] { new PackageFragmentValidationResult(PackageFragmentValidationResultType.Fatal, exception) }
            }
            ;

            PackageAssemblyHandler.ClearAssemblyList();

            XElement installElement;
            PackageFragmentValidationResult packageFragmentValidationResult = XmlHelper.LoadInstallXml(this.ZipFilename, out installElement);

            if (packageFragmentValidationResult != null)
            {
                return new [] { packageFragmentValidationResult }
            }
            ;

            XElement packageFragmentInstallerBinariesElement = installElement.Element(XmlUtils.GetXName(PackageSystemSettings.XmlNamespace, PackageSystemSettings.PackageFragmentInstallerBinariesElementName));

            if (packageFragmentInstallerBinariesElement != null)
            {
                List <PackageFragmentValidationResult> result1 = LoadPackageFragmentInstallerBinaries(packageFragmentInstallerBinariesElement).ToList();

                if (result1.Count > 0)
                {
                    return(result1);
                }
            }

            XElement packageFragmentInstallersElement = installElement.Element(XmlUtils.GetXName(PackageSystemSettings.XmlNamespace, PackageSystemSettings.PackageFragmentInstallersElementName));

            if (packageFragmentInstallersElement == null)
            {
                return new [] { new PackageFragmentValidationResult(PackageFragmentValidationResultType.Fatal, string.Format("The {0} file is wrongly formatted", PackageSystemSettings.InstallFilename)) }
            }
            ;

            var result2 = LoadPackageFragmentInstallers(packageFragmentInstallersElement);

            if (result2.Count > 0)
            {
                return(result2);
            }

            return(new PackageFragmentValidationResult[] { });
        }
Ejemplo n.º 2
0
        private IEnumerable<PackageFragmentValidationResult> Initialize()
        {
            if (_isInitialized) throw new InvalidOperationException("Initialize() may only be called once");
            _isInitialized = true;

            Exception exception = null;
            try
            {
                _packageInstallerContex = new PackageInstallerContext(new ZipFileSystem(this.ZipFilename), this.PackageInstallDirectory, this.TempDirectory, this.PackageInformation);
            }
            catch (Exception ex)
            {
                exception = ex;
            }
            if (exception != null) return new [] { new PackageFragmentValidationResult(PackageFragmentValidationResultType.Fatal, exception) };

            PackageAssemblyHandler.ClearAssemblyList();

            XElement installElement;
            PackageFragmentValidationResult packageFragmentValidationResult = XmlHelper.LoadInstallXml(this.ZipFilename, out installElement);
            if (packageFragmentValidationResult != null) return new [] { packageFragmentValidationResult };

            XElement packageFragmentInstallerBinariesElement = installElement.Element(XmlUtils.GetXName(PackageSystemSettings.XmlNamespace, PackageSystemSettings.PackageFragmentInstallerBinariesElementName));
            if (packageFragmentInstallerBinariesElement != null)
            {
                List<PackageFragmentValidationResult> result1 = LoadPackageFragmentInstallerBinaries(packageFragmentInstallerBinariesElement).ToList();
                if (result1.Count > 0) return result1;
            }

            XElement packageFragmentInstallersElement = installElement.Element(XmlUtils.GetXName(PackageSystemSettings.XmlNamespace, PackageSystemSettings.PackageFragmentInstallersElementName));
            if (packageFragmentInstallersElement == null) return new [] { new PackageFragmentValidationResult(PackageFragmentValidationResultType.Fatal, string.Format("The {0} file is wrongly formatted", PackageSystemSettings.InstallFilename)) };

            var result2 = LoadPackageFragmentInstallers(packageFragmentInstallersElement);
            if (result2.Count > 0) return result2;

            return new PackageFragmentValidationResult[] { };
        }