private static AssemblyManifest DownloadDeploymentManifestDirectBypass(SubscriptionStore subStore, ref Uri sourceUri, out TempFile tempFile, out SubscriptionState subState, IDownloadNotification notification, DownloadOptions options, out ServerInformation serverInformation)
 {
     Logger.AddMethodCall("DownloadDeploymentManifestDirectBypass called.");
     subState = null;
     tempFile = subStore.AcquireTempFile(".application");
     DownloadManifestAsRawFile(ref sourceUri, tempFile.Path, notification, options, out serverInformation);
     bool flag = false;
     AssemblyManifest deployment = null;
     DefinitionIdentity identity = null;
     DefinitionIdentity identity2 = null;
     DefinitionAppId appId = null;
     try
     {
         deployment = ManifestReader.FromDocumentNoValidation(tempFile.Path);
         identity = deployment.Identity;
         identity2 = new DefinitionIdentity(deployment.MainDependentAssembly.Identity);
         Uri uri = ((sourceUri.Query != null) && (sourceUri.Query.Length > 0)) ? new Uri(sourceUri.GetLeftPart(UriPartial.Path)) : sourceUri;
         appId = new DefinitionAppId(uri.AbsoluteUri, new DefinitionIdentity[] { identity, identity2 });
         Logger.AddInternalState("expectedAppId=" + appId.ToString());
     }
     catch (InvalidDeploymentException)
     {
         flag = true;
     }
     catch (COMException)
     {
         flag = true;
     }
     catch (SEHException)
     {
         flag = true;
     }
     catch (IndexOutOfRangeException)
     {
         flag = true;
     }
     if (!flag)
     {
         long num;
         SubscriptionState subscriptionState = subStore.GetSubscriptionState(deployment);
         bool flag2 = false;
         using (subStore.AcquireReferenceTransaction(out num))
         {
             flag2 = subStore.CheckAndReferenceApplication(subscriptionState, appId, num);
         }
         if (flag2 && appId.Equals(subscriptionState.CurrentBind))
         {
             Logger.AddInternalState("Application is found in store and it is the CurrentBind, bypass validation and further downloads.");
             subState = subscriptionState;
             return subState.CurrentDeploymentManifest;
         }
         flag = true;
         if (flag2)
         {
             Logger.AddInternalState("Application is found in store and but it is not the CurrentBind.");
         }
     }
     else
     {
         Logger.AddInternalState("Application is not found in store.");
     }
     Logger.AddInternalState("Reparse the deployment manifest for validations.");
     AssemblyManifest manifest2 = ManifestReader.FromDocument(tempFile.Path, AssemblyManifest.ManifestType.Deployment, sourceUri);
     if (manifest2.Identity.Version == null)
     {
         throw new InvalidDeploymentException(ExceptionTypes.ManifestSemanticValidation, Resources.GetString("Ex_DeploymentManifestNoVersion"));
     }
     if (manifest2.Deployment == null)
     {
         throw new InvalidDeploymentException(ExceptionTypes.ManifestSemanticValidation, Resources.GetString("Ex_InvalidDeploymentManifest"));
     }
     return manifest2;
 }
Beispiel #2
0
        private static AssemblyManifest DownloadDeploymentManifestDirectBypass(SubscriptionStore subStore, ref Uri sourceUri, out TempFile tempFile, out SubscriptionState subState, IDownloadNotification notification, DownloadOptions options, out ServerInformation serverInformation)
        {
            Logger.AddMethodCall("DownloadDeploymentManifestDirectBypass called.");
            subState = (SubscriptionState)null;
            tempFile = subStore.AcquireTempFile(".application");
            DownloadManager.DownloadManifestAsRawFile(ref sourceUri, tempFile.Path, notification, options, out serverInformation);
            bool             flag1      = false;
            AssemblyManifest deployment = (AssemblyManifest)null;
            DefinitionAppId  appId      = (DefinitionAppId)null;

            try
            {
                deployment = ManifestReader.FromDocumentNoValidation(tempFile.Path);
                DefinitionIdentity identity           = deployment.Identity;
                DefinitionIdentity definitionIdentity = new DefinitionIdentity(deployment.MainDependentAssembly.Identity);
                appId = new DefinitionAppId((sourceUri.Query == null || sourceUri.Query.Length <= 0 ? sourceUri : new Uri(sourceUri.GetLeftPart(UriPartial.Path))).AbsoluteUri, new DefinitionIdentity[2]
                {
                    identity,
                    definitionIdentity
                });
                Logger.AddInternalState("expectedAppId=" + appId.ToString());
            }
            catch (InvalidDeploymentException ex)
            {
                flag1 = true;
            }
            catch (COMException ex)
            {
                flag1 = true;
            }
            catch (SEHException ex)
            {
                flag1 = true;
            }
            catch (IndexOutOfRangeException ex)
            {
                flag1 = true;
            }
            if (!flag1)
            {
                SubscriptionState subscriptionState = subStore.GetSubscriptionState(deployment);
                bool flag2 = false;
                long transactionId;
                using (subStore.AcquireReferenceTransaction(out transactionId))
                    flag2 = subStore.CheckAndReferenceApplication(subscriptionState, appId, transactionId);
                if (!flag2 || !appId.Equals((object)subscriptionState.CurrentBind))
                {
                    if (flag2)
                    {
                        Logger.AddInternalState("Application is found in store and but it is not the CurrentBind.");
                    }
                }
                else
                {
                    Logger.AddInternalState("Application is found in store and it is the CurrentBind, bypass validation and further downloads.");
                    subState = subscriptionState;
                    return(subState.CurrentDeploymentManifest);
                }
            }
            else
            {
                Logger.AddInternalState("Application is not found in store.");
            }
            Logger.AddInternalState("Reparse the deployment manifest for validations.");
            AssemblyManifest assemblyManifest = ManifestReader.FromDocument(tempFile.Path, AssemblyManifest.ManifestType.Deployment, sourceUri);

            if (assemblyManifest.Identity.Version == (Version)null)
            {
                throw new InvalidDeploymentException(ExceptionTypes.ManifestSemanticValidation, Resources.GetString("Ex_DeploymentManifestNoVersion"));
            }
            if (assemblyManifest.Deployment == null)
            {
                throw new InvalidDeploymentException(ExceptionTypes.ManifestSemanticValidation, Resources.GetString("Ex_InvalidDeploymentManifest"));
            }
            return(assemblyManifest);
        }