internal static AssemblyManifest FromDocument(string localPath, AssemblyManifest.ManifestType manifestType, Uri sourceUri)
 {
     AssemblyManifest manifest;
     CodeMarker_Singleton.Instance.CodeMarker(CodeMarkerEvent.perfParseBegin);
     Logger.AddMethodCall("ManifestReader.FromDocument(" + localPath + ") called.");
     FileInfo info = new FileInfo(localPath);
     if (info.Length > 0x1000000L)
     {
         throw new DeploymentException(Resources.GetString("Ex_ManifestFileTooLarge"));
     }
     FileStream input = new FileStream(localPath, FileMode.Open, FileAccess.Read);
     try
     {
         XmlReader reader = PolicyKeys.SkipSchemaValidation() ? XmlReader.Create(input) : ManifestValidatingReader.Create(input);
         while (reader.Read())
         {
         }
         Logger.AddInternalState("Schema validation passed.");
         manifest = new AssemblyManifest(input);
         Logger.AddInternalState("Manifest is parsed successfully.");
         if (!PolicyKeys.SkipSemanticValidation())
         {
             manifest.ValidateSemantics(manifestType);
         }
         Logger.AddInternalState("Semantic validation passed.");
         if (!PolicyKeys.SkipSignatureValidation())
         {
             input.Position = 0L;
             manifest.ValidateSignature(input);
         }
         Logger.AddInternalState("Signature validation passed.");
     }
     catch (XmlException exception)
     {
         string message = string.Format(CultureInfo.CurrentUICulture, Resources.GetString("Ex_ManifestFromDocument"), new object[] { (sourceUri != null) ? sourceUri.AbsoluteUri : Path.GetFileName(localPath) });
         throw new InvalidDeploymentException(ExceptionTypes.ManifestParse, message, exception);
     }
     catch (XmlSchemaValidationException exception2)
     {
         string str2 = string.Format(CultureInfo.CurrentUICulture, Resources.GetString("Ex_ManifestFromDocument"), new object[] { (sourceUri != null) ? sourceUri.AbsoluteUri : Path.GetFileName(localPath) });
         throw new InvalidDeploymentException(ExceptionTypes.ManifestParse, str2, exception2);
     }
     catch (InvalidDeploymentException exception3)
     {
         string str3 = string.Format(CultureInfo.CurrentUICulture, Resources.GetString("Ex_ManifestFromDocument"), new object[] { (sourceUri != null) ? sourceUri.AbsoluteUri : Path.GetFileName(localPath) });
         throw new InvalidDeploymentException(ExceptionTypes.ManifestParse, str3, exception3);
     }
     finally
     {
         if (input != null)
         {
             input.Dispose();
         }
     }
     CodeMarker_Singleton.Instance.CodeMarker(CodeMarkerEvent.perfParseEnd);
     return manifest;
 }
 public static void VerifyStrongNameAssembly(string filePath, AssemblyManifest assemblyManifest)
 {
     string fileName = Path.GetFileName(filePath);
     if (assemblyManifest.Identity.PublicKeyToken == null)
     {
         throw new InvalidDeploymentException(ExceptionTypes.Validation, string.Format(CultureInfo.CurrentUICulture, Resources.GetString("Ex_StrongNameAsmWithNoPKT"), new object[] { fileName }));
     }
     bool ignoreSelfReferentialFileHash = false;
     if (assemblyManifest.ManifestSourceFormat == ManifestSourceFormat.XmlFile)
     {
         assemblyManifest.ValidateSignature(null);
     }
     else if (assemblyManifest.ManifestSourceFormat == ManifestSourceFormat.ID_1)
     {
         bool flag2;
         if (assemblyManifest.ComplibIdentity == null)
         {
             byte[] buffer = null;
             PEStream stream = null;
             MemoryStream s = null;
             try
             {
                 stream = new PEStream(filePath, true);
                 buffer = stream.GetDefaultId1ManifestResource();
                 if (buffer != null)
                 {
                     s = new MemoryStream(buffer);
                 }
                 if (s == null)
                 {
                     throw new InvalidDeploymentException(ExceptionTypes.StronglyNamedAssemblyVerification, string.Format(CultureInfo.CurrentUICulture, Resources.GetString("Ex_StronglyNamedAssemblyNotVerifiable"), new object[] { fileName }));
                 }
                 assemblyManifest.ValidateSignature(s);
                 goto Label_01C3;
             }
             finally
             {
                 if (stream != null)
                 {
                     stream.Close();
                 }
                 if (s != null)
                 {
                     s.Close();
                 }
             }
         }
         if (!assemblyManifest.ComplibIdentity.Equals(assemblyManifest.Identity))
         {
             throw new InvalidDeploymentException(ExceptionTypes.IdentityMatchValidationForMixedModeAssembly, string.Format(CultureInfo.CurrentUICulture, Resources.GetString("Ex_IdentitiesDoNotMatchForMixedModeAssembly"), new object[] { fileName }));
         }
         if (!Microsoft.Runtime.Hosting.StrongNameHelpers.StrongNameSignatureVerificationEx(filePath, false, out flag2))
         {
             throw new InvalidDeploymentException(ExceptionTypes.SignatureValidation, string.Format(CultureInfo.CurrentUICulture, Resources.GetString("Ex_StrongNameSignatureInvalid"), new object[] { fileName }));
         }
         ignoreSelfReferentialFileHash = true;
     }
     else
     {
         bool flag3;
         if (assemblyManifest.ManifestSourceFormat != ManifestSourceFormat.CompLib)
         {
             throw new InvalidDeploymentException(ExceptionTypes.StronglyNamedAssemblyVerification, string.Format(CultureInfo.CurrentUICulture, Resources.GetString("Ex_StronglyNamedAssemblyNotVerifiable"), new object[] { fileName }));
         }
         if (!Microsoft.Runtime.Hosting.StrongNameHelpers.StrongNameSignatureVerificationEx(filePath, false, out flag3))
         {
             throw new InvalidDeploymentException(ExceptionTypes.SignatureValidation, string.Format(CultureInfo.CurrentUICulture, Resources.GetString("Ex_StrongNameSignatureInvalid"), new object[] { fileName }));
         }
         ignoreSelfReferentialFileHash = true;
     }
 Label_01C3:
     VerifyManifestComponentFiles(assemblyManifest, filePath, ignoreSelfReferentialFileHash);
 }