private bool DownloadApplication(SubscriptionState subState, ActivationDescription actDesc, long transactionId, out TempDirectory downloadTemp)
 {
     Uri uri;
     string str;
     bool flag = false;
     Logger.AddMethodCall("DownloadApplication called.");
     downloadTemp = this._subStore.AcquireTempDirectory();
     Logger.AddInternalState("Start processing application manifest.");
     AssemblyManifest appManifest = DownloadManager.DownloadApplicationManifest(actDesc.DeployManifest, downloadTemp.Path, actDesc.DeploySourceUri, out uri, out str);
     AssemblyManifest.ReValidateManifestSignatures(actDesc.DeployManifest, appManifest);
     if (appManifest.EntryPoints[0].HostInBrowser)
     {
         throw new DeploymentException(ExceptionTypes.ManifestSemanticValidation, Resources.GetString("Ex_HostInBrowserAppNotSupported"));
     }
     if (appManifest.EntryPoints[0].CustomHostSpecified)
     {
         throw new DeploymentException(ExceptionTypes.ManifestSemanticValidation, Resources.GetString("Ex_CustomHostSpecifiedAppNotSupported"));
     }
     if (appManifest.EntryPoints[0].CustomUX && (((actDesc.ActType == ActivationType.InstallViaDotApplication) || (actDesc.ActType == ActivationType.InstallViaFileAssociation)) || ((actDesc.ActType == ActivationType.InstallViaShortcut) || (actDesc.ActType == ActivationType.None))))
     {
         throw new DeploymentException(ExceptionTypes.ManifestSemanticValidation, Resources.GetString("Ex_CustomUXAppNotSupported"));
     }
     Logger.AddPhaseInformation(Resources.GetString("PhaseLog_ProcessingApplicationManifestComplete"));
     Logger.AddInternalState("Processing of application manifest has successfully completed.");
     actDesc.SetApplicationManifest(appManifest, uri, str);
     Logger.SetApplicationManifest(appManifest);
     this._subStore.CheckCustomUXFlag(subState, actDesc.AppManifest);
     actDesc.AppId = new DefinitionAppId(actDesc.ToAppCodebase(), new DefinitionIdentity[] { actDesc.DeployManifest.Identity, actDesc.AppManifest.Identity });
     Logger.AddInternalState("Start request of trust and detection of platform.");
     if (appManifest.EntryPoints[0].CustomUX)
     {
         Logger.AddInternalState("This is a CustomUX application. Calling PersistTrustWithoutEvaluation.");
         actDesc.Trust = ApplicationTrust.PersistTrustWithoutEvaluation(actDesc.ToActivationContext());
     }
     else
     {
         this._ui.Hide();
         if (this._ui.SplashCancelled())
         {
             throw new DownloadCancelledException();
         }
         if (subState.IsInstalled && !string.Equals(subState.EffectiveCertificatePublicKeyToken, actDesc.EffectiveCertificatePublicKeyToken, StringComparison.Ordinal))
         {
             Logger.AddInternalState("EffectiveCertificatePublicKeyToken has changed between versions: subState.EffectiveCertificatePublicKeyToken=" + subState.EffectiveCertificatePublicKeyToken + ",actDesc.EffectiveCertificatePublicKeyToken=" + actDesc.EffectiveCertificatePublicKeyToken);
             Logger.AddInternalState("Removing the cached trust decision for CurrentBind.");
             ApplicationTrust.RemoveCachedTrust(subState.CurrentBind);
         }
         try
         {
             actDesc.Trust = ApplicationTrust.RequestTrust(subState, actDesc.DeployManifest.Deployment.Install, actDesc.IsUpdate, actDesc.ToActivationContext());
         }
         catch (Exception exception)
         {
             Logger.AddErrorInformation(Resources.GetString("Ex_DetermineTrustFailed"), exception);
             if (!(exception is TrustNotGrantedException))
             {
                 try
                 {
                     PlatformDetector.VerifyPlatformDependencies(actDesc.AppManifest, actDesc.DeployManifest, downloadTemp.Path);
                 }
                 catch (Exception exception2)
                 {
                     if (exception2 is DependentPlatformMissingException)
                     {
                         throw new DeploymentException(ExceptionTypes.TrustFailDependentPlatform, string.Format(CultureInfo.CurrentUICulture, Resources.GetString("ErrorMessage_TrustFailDependentPlatformMissing"), new object[] { exception2.Message }), exception);
                     }
                 }
             }
             throw;
         }
     }
     this._fullTrust = actDesc.Trust.DefaultGrantSet.PermissionSet.IsUnrestricted();
     Logger.AddInternalState("_fullTrust = " + this._fullTrust.ToString());
     if (!this._fullTrust && (actDesc.AppManifest.FileAssociations.Length > 0))
     {
         throw new DeploymentException(ExceptionTypes.ManifestSemanticValidation, Resources.GetString("Ex_FileExtensionNotSupported"));
     }
     PlatformDetector.VerifyPlatformDependencies(actDesc.AppManifest, actDesc.DeployManifest, downloadTemp.Path);
     Logger.AddPhaseInformation(Resources.GetString("PhaseLog_PlatformDetectAndTrustGrantComplete"));
     Logger.AddInternalState("Request of trust and detection of platform is complete.");
     Logger.AddInternalState("Start downloading  and verifying dependencies.");
     if (!this._subStore.CheckAndReferenceApplication(subState, actDesc.AppId, transactionId))
     {
         flag = true;
         Description effectiveDescription = actDesc.EffectiveDescription;
         UserInterfaceInfo info = new UserInterfaceInfo {
             productName = effectiveDescription.Product
         };
         if (actDesc.IsUpdate)
         {
             if (actDesc.IsRequiredUpdate)
             {
                 info.formTitle = string.Format(CultureInfo.CurrentUICulture, Resources.GetString("UI_ProgressTitleRequiredUpdate"), new object[] { info.productName });
             }
             else
             {
                 info.formTitle = string.Format(CultureInfo.CurrentUICulture, Resources.GetString("UI_ProgressTitleUpdate"), new object[] { info.productName });
             }
         }
         else if (!actDesc.DeployManifest.Deployment.Install)
         {
             info.formTitle = string.Format(CultureInfo.CurrentUICulture, Resources.GetString("UI_ProgressTitleDownload"), new object[] { info.productName });
         }
         else
         {
             info.formTitle = string.Format(CultureInfo.CurrentUICulture, Resources.GetString("UI_ProgressTitleInstall"), new object[] { info.productName });
         }
         info.supportUrl = effectiveDescription.SupportUrl;
         info.sourceSite = UserInterface.GetDisplaySite(actDesc.DeploySourceUri);
         if ((appManifest.Description != null) && (appManifest.Description.IconFileFS != null))
         {
             info.iconFilePath = Path.Combine(downloadTemp.Path, appManifest.Description.IconFileFS);
         }
         ProgressPiece notification = this._ui.ShowProgress(info);
         DownloadOptions options = null;
         bool flag2 = !actDesc.DeployManifest.Deployment.Install;
         if (!this._fullTrust && flag2)
         {
             options = new DownloadOptions {
                 EnforceSizeLimit = true,
                 SizeLimit = this._subStore.GetSizeLimitInBytesForSemiTrustApps(),
                 Size = actDesc.DeployManifest.SizeInBytes + actDesc.AppManifest.SizeInBytes
             };
         }
         DownloadManager.DownloadDependencies(subState, actDesc.DeployManifest, actDesc.AppManifest, actDesc.AppSourceUri, downloadTemp.Path, null, notification, options);
         Logger.AddPhaseInformation(Resources.GetString("PhaseLog_DownloadDependenciesComplete"));
         actDesc.CommitApp = true;
         actDesc.AppPayloadPath = downloadTemp.Path;
         actDesc.AppGroup = null;
     }
     return flag;
 }