Example #1
0
        public DependentAssembly(System.Deployment.Internal.Isolation.Manifest.AssemblyReferenceEntry assemblyReferenceEntry)
        {
            this._hashCollection = new System.Deployment.Application.HashCollection();
            System.Deployment.Internal.Isolation.Manifest.AssemblyReferenceDependentAssemblyEntry dependentAssembly = assemblyReferenceEntry.DependentAssembly;
            this._size     = dependentAssembly.Size;
            this._codebase = dependentAssembly.Codebase;
            this._group    = dependentAssembly.Group;
            bool flag = false;

            System.Deployment.Internal.Isolation.ISection hashElements = dependentAssembly.HashElements;
            uint celt = (hashElements != null) ? hashElements.Count : 0;

            if (celt > 0)
            {
                uint celtFetched = 0;
                System.Deployment.Internal.Isolation.Manifest.IHashElementEntry[] rgelt = new System.Deployment.Internal.Isolation.Manifest.IHashElementEntry[celt];
                System.Deployment.Internal.Isolation.IEnumUnknown unknown = (System.Deployment.Internal.Isolation.IEnumUnknown)hashElements._NewEnum;
                Marshal.ThrowExceptionForHR(unknown.Next(celt, rgelt, ref celtFetched));
                if (celtFetched != celt)
                {
                    throw new InvalidDeploymentException(ExceptionTypes.Manifest, Resources.GetString("Ex_IsoEnumFetchNotEqualToCount"));
                }
                for (uint i = 0; i < celt; i++)
                {
                    System.Deployment.Internal.Isolation.Manifest.HashElementEntry allData = rgelt[i].AllData;
                    if (allData.DigestValueSize > 0)
                    {
                        byte[] destination = new byte[allData.DigestValueSize];
                        Marshal.Copy(allData.DigestValue, destination, 0, (int)allData.DigestValueSize);
                        this._hashCollection.AddHash(destination, (System.Deployment.Internal.Isolation.Manifest.CMS_HASH_DIGESTMETHOD)allData.DigestMethod, (System.Deployment.Internal.Isolation.Manifest.CMS_HASH_TRANSFORM)allData.Transform);
                        flag = true;
                    }
                }
            }
            if (!flag && (dependentAssembly.HashValueSize > 0))
            {
                byte[] buffer2 = new byte[dependentAssembly.HashValueSize];
                Marshal.Copy(dependentAssembly.HashValue, buffer2, 0, (int)dependentAssembly.HashValueSize);
                this._hashCollection.AddHash(buffer2, (System.Deployment.Internal.Isolation.Manifest.CMS_HASH_DIGESTMETHOD)dependentAssembly.HashAlgorithm, System.Deployment.Internal.Isolation.Manifest.CMS_HASH_TRANSFORM.CMS_HASH_TRANSFORM_IDENTITY);
            }
            this._preRequisite = (dependentAssembly.Flags & 4) != 0;
            this._optional     = (assemblyReferenceEntry.Flags & 1) != 0;
            this._visible      = (dependentAssembly.Flags & 2) != 0;
            this._resourceFallbackCultureInternal = (dependentAssembly.Flags & 8) != 0;
            this._resourceFallbackCulture         = dependentAssembly.ResourceFallbackCulture;
            this._description = dependentAssembly.Description;
            this._supportUrl  = AssemblyManifest.UriFromMetadataEntry(dependentAssembly.SupportUrl, "Ex_DependencySupportUrlNotValid");
            System.Deployment.Internal.Isolation.IReferenceIdentity referenceIdentity = assemblyReferenceEntry.ReferenceIdentity;
            this._identity   = new System.Deployment.Application.ReferenceIdentity(referenceIdentity);
            this._codebaseFS = UriHelper.NormalizePathDirectorySeparators(this._codebase);
        }
        public File(System.Deployment.Internal.Isolation.Manifest.FileEntry fileEntry)
        {
            this._hashCollection = new System.Deployment.Application.HashCollection();
            this._name           = fileEntry.Name;
            this._loadFrom       = fileEntry.LoadFrom;
            this._size           = fileEntry.Size;
            this._group          = fileEntry.Group;
            this._optional       = (fileEntry.Flags & 1) != 0;
            this._isData         = (fileEntry.WritableType & 2) != 0;
            bool flag = false;

            System.Deployment.Internal.Isolation.ISection hashElements = fileEntry.HashElements;
            uint celt = (hashElements != null) ? hashElements.Count : 0;

            if (celt > 0)
            {
                uint celtFetched = 0;
                System.Deployment.Internal.Isolation.Manifest.IHashElementEntry[] rgelt = new System.Deployment.Internal.Isolation.Manifest.IHashElementEntry[celt];
                System.Deployment.Internal.Isolation.IEnumUnknown unknown = (System.Deployment.Internal.Isolation.IEnumUnknown)hashElements._NewEnum;
                Marshal.ThrowExceptionForHR(unknown.Next(celt, rgelt, ref celtFetched));
                if (celtFetched != celt)
                {
                    throw new InvalidDeploymentException(ExceptionTypes.Manifest, Resources.GetString("Ex_IsoEnumFetchNotEqualToCount"));
                }
                for (uint i = 0; i < celt; i++)
                {
                    System.Deployment.Internal.Isolation.Manifest.HashElementEntry allData = rgelt[i].AllData;
                    if (allData.DigestValueSize > 0)
                    {
                        byte[] destination = new byte[allData.DigestValueSize];
                        Marshal.Copy(allData.DigestValue, destination, 0, (int)allData.DigestValueSize);
                        this._hashCollection.AddHash(destination, (System.Deployment.Internal.Isolation.Manifest.CMS_HASH_DIGESTMETHOD)allData.DigestMethod, (System.Deployment.Internal.Isolation.Manifest.CMS_HASH_TRANSFORM)allData.Transform);
                        flag = true;
                    }
                }
            }
            if (!flag && (fileEntry.HashValueSize > 0))
            {
                byte[] buffer2 = new byte[fileEntry.HashValueSize];
                Marshal.Copy(fileEntry.HashValue, buffer2, 0, (int)fileEntry.HashValueSize);
                this._hashCollection.AddHash(buffer2, (System.Deployment.Internal.Isolation.Manifest.CMS_HASH_DIGESTMETHOD)fileEntry.HashAlgorithm, System.Deployment.Internal.Isolation.Manifest.CMS_HASH_TRANSFORM.CMS_HASH_TRANSFORM_IDENTITY);
            }
            this._nameFS = UriHelper.NormalizePathDirectorySeparators(this._name);
        }