Init() приватный Метод

private Init ( String name, byte publicKey, byte publicKeyToken, Version version, System.Globalization.CultureInfo cultureInfo, AssemblyHashAlgorithm hashAlgorithm, AssemblyVersionCompatibility versionCompatibility, String codeBase, AssemblyNameFlags flags, StrongNameKeyPair keyPair ) : void
name String
publicKey byte
publicKeyToken byte
version Version
cultureInfo System.Globalization.CultureInfo
hashAlgorithm AssemblyHashAlgorithm
versionCompatibility AssemblyVersionCompatibility
codeBase String
flags AssemblyNameFlags
keyPair StrongNameKeyPair
Результат void
Пример #1
0
        // If the assembly is copied before it is loaded, the codebase will be set to the
        // actual file loaded if copiedName is true. If it is false, then the original code base
        // is returned.
        public override AssemblyName GetName(bool copiedName)
        {
            AssemblyName an = new AssemblyName();

            string codeBase = GetCodeBase(copiedName);

            an.Init(GetSimpleName(),
                    GetPublicKey(),
                    null, // public key token
                    GetVersion(),
                    GetLocale(),
                    GetHashAlgorithm(),
                    AssemblyVersionCompatibility.SameMachine,
                    codeBase,
                    GetFlags() | AssemblyNameFlags.PublicKey,
                    null); // strong name key pair

            Module manifestModule = ManifestModule;

            if (manifestModule != null)
            {
                if (manifestModule.MDStreamVersion > 0x10000)
                {
                    ManifestModule.GetPEKind(out PortableExecutableKinds pek, out ImageFileMachine ifm);
                    an.SetProcArchIndex(pek, ifm);
                }
            }
            return(an);
        }
Пример #2
0
 public object Clone()
 {
     AssemblyName name = new AssemblyName();
     name.Init(this._Name, this._PublicKey, this._PublicKeyToken, this._Version, this._CultureInfo, this._HashAlgorithm, this._VersionCompatibility, this._CodeBase, this._Flags, this._StrongNameKeyPair);
     name._HashForControl = this._HashForControl;
     name._HashAlgorithmForControl = this._HashAlgorithmForControl;
     return name;
 }
        /// <summary>Makes a copy of this <see cref="T:System.Reflection.AssemblyName" /> object.</summary>
        /// <returns>An object that is a copy of this <see cref="T:System.Reflection.AssemblyName" /> object.</returns>
        // Token: 0x0600436E RID: 17262 RVA: 0x000F7CE0 File Offset: 0x000F5EE0
        public object Clone()
        {
            AssemblyName assemblyName = new AssemblyName();

            assemblyName.Init(this._Name, this._PublicKey, this._PublicKeyToken, this._Version, this._CultureInfo, this._HashAlgorithm, this._VersionCompatibility, this._CodeBase, this._Flags, this._StrongNameKeyPair);
            assemblyName._HashForControl          = this._HashForControl;
            assemblyName._HashAlgorithmForControl = this._HashAlgorithmForControl;
            return(assemblyName);
        }
Пример #4
0
        // Make a copy of this assembly name.
        public Object Clone()
        {
            AssemblyName name = new AssemblyName();

            name.Init(_Name,
                      _PublicKey,
                      _PublicKeyToken,
                      _Version,
                      _CultureInfo,
                      _HashAlgorithm,
                      _VersionCompatibility,
                      _CodeBase,
                      _Flags,
                      _StrongNameKeyPair);
            name._HashForControl          = _HashForControl;
            name._HashAlgorithmForControl = _HashAlgorithmForControl;
            return(name);
        }
Пример #5
0
        // Make a copy of this assembly name.
        public object Clone()
        {
            AssemblyName name = new AssemblyName();

            name.Init(_name,
                      _publicKey,
                      _publicKeyToken,
                      _version,
                      _cultureInfo,
                      _hashAlgorithm,
                      _versionCompatibility,
                      _codeBase,
                      _flags,
                      _strongNameKeyPair);
            name._hashForControl          = _hashForControl;
            name._hashAlgorithmForControl = _hashAlgorithmForControl;
            return(name);
        }
Пример #6
0
        public override AssemblyName GetName(bool copiedName)
        {
            AssemblyName name     = new AssemblyName();
            string       codeBase = this.GetCodeBase(copiedName);

            this.VerifyCodeBaseDiscovery(codeBase);
            name.Init(this.GetSimpleName(), this.GetPublicKey(), null, this.GetVersion(), this.GetLocale(), this.GetHashAlgorithm(), AssemblyVersionCompatibility.SameMachine, codeBase, this.GetFlags() | AssemblyNameFlags.PublicKey, null);
            Module manifestModule = this.ManifestModule;

            if ((manifestModule != null) && (manifestModule.MDStreamVersion > 0x10000))
            {
                PortableExecutableKinds kinds;
                ImageFileMachine        machine;
                this.ManifestModule.GetPEKind(out kinds, out machine);
                name.SetProcArchIndex(kinds, machine);
            }
            return(name);
        }
Пример #7
0
        /// <summary>制作此 <see cref="T:System.Reflection.AssemblyName" /> 对象的副本。</summary>
        /// <returns>作为 <see cref="T:System.Reflection.AssemblyName" /> 对象副本的对象。</returns>
        public object Clone()
        {
            AssemblyName assemblyName = new AssemblyName();
            string       name         = this._Name;

            byte[]            publicKey      = this._PublicKey;
            byte[]            publicKeyToken = this._PublicKeyToken;
            Version           version        = this._Version;
            CultureInfo       cultureInfo    = this._CultureInfo;
            int               num1           = (int)this._HashAlgorithm;
            int               num2           = (int)this._VersionCompatibility;
            string            codeBase       = this._CodeBase;
            int               num3           = (int)this._Flags;
            StrongNameKeyPair keyPair        = this._StrongNameKeyPair;

            assemblyName.Init(name, publicKey, publicKeyToken, version, cultureInfo, (AssemblyHashAlgorithm)num1, (AssemblyVersionCompatibility)num2, codeBase, (AssemblyNameFlags)num3, keyPair);
            byte[] numArray = this._HashForControl;
            assemblyName._HashForControl = numArray;
            int num4 = (int)this._HashAlgorithmForControl;

            assemblyName._HashAlgorithmForControl = (AssemblyHashAlgorithm)num4;
            return((object)assemblyName);
        }
Пример #8
0
        [System.Security.SecurityCritical]  // auto-generated
        private void InitSafeToDeserializeArray()
        {
            _safeToDeserialize = new bool[_typeTable.Length];
            for(int i=0; i<_typeTable.Length; i++) {
                long oldPos = _store.BaseStream.Position;
                String typeName;
                try {
                    _store.BaseStream.Position = _typeNamePositions[i];
                    typeName = _store.ReadString();
                }
                finally {
                    _store.BaseStream.Position = oldPos;
                }

                AssemblyName an;
                String typePart;
                RuntimeType resourceType = (RuntimeType)Type.GetType(typeName, false);
                if (resourceType == null) {
                    an = null;
                    typePart = typeName;
                }
                else {
                    // Enums should be safe to deserialize, and this helps out
                    // partially trusted, localized [....] apps.
                    if (resourceType.BaseType == typeof(Enum)) {
                        _safeToDeserialize[i] = true;
                        continue;
                    }

                    // For most types, check our TypesSafeForDeserialization.
                    typePart = resourceType.FullName;

                    an = new AssemblyName();
                    
                    // resourceType is retrieved via Type.GetType and must be a RuntimeType
                    RuntimeAssembly a = (RuntimeAssembly)resourceType.Assembly;
                    an.Init(a.GetSimpleName(), 
                            a.GetPublicKey(),
                            null, // public key token
                            null, // version
                            a.GetLocale(),
                            AssemblyHashAlgorithm.None,
                            AssemblyVersionCompatibility.SameMachine,
                            null, // codebase
                            AssemblyNameFlags.PublicKey,
                            null); // strong name key pair
                }

                foreach(String safeType in TypesSafeForDeserialization) {
                    if (ResourceManager.CompareNames(safeType, typePart, an)) {
#if _DEBUG
                        if (ResourceManager.DEBUG >= 7)
                            Console.WriteLine("ResReader: Found a type-safe type to deserialize!  Type name: {0}", typeName);
#endif
                        _safeToDeserialize[i] = true;
                        continue;
                    }
                }

#if _DEBUG
                if (ResourceManager.DEBUG >= 7)
                    if (!_safeToDeserialize[i])
                        Console.WriteLine("ResReader: Found a type that wasn't safe to deserialize: {0}", typeName);
#endif
            }
        }
Пример #9
0
        public override AssemblyName GetName(bool copiedName)
        {
            AssemblyName an = new AssemblyName();

            String codeBase = GetCodeBase(copiedName);
            VerifyCodeBaseDiscovery(codeBase);

            an.Init(GetSimpleName(), 
                    GetPublicKey(),
                    null, // public key token
                    GetVersion(),
                    GetLocale(),
                    GetHashAlgorithm(),
                    AssemblyVersionCompatibility.SameMachine,
                    codeBase,
                    GetFlags() | AssemblyNameFlags.PublicKey,
                    null); // strong name key pair

            PortableExecutableKinds pek;
            ImageFileMachine ifm;
        
            Module manifestModule = ManifestModule;
            if (manifestModule != null)
            {
                if (manifestModule.MDStreamVersion > 0x10000)
                {
                    ManifestModule.GetPEKind(out pek, out ifm);
                    an.SetProcArchIndex(pek,ifm);
                }
            }
            return an;
        }
Пример #10
0
 // Make a copy of this assembly name.
 public Object Clone()
 {
     AssemblyName name = new AssemblyName();
     name.Init(_Name,
               _PublicKey,
               _PublicKeyToken,
               _Version,
               _CultureInfo,
               _HashAlgorithm,
               _VersionCompatibility,
               _CodeBase,
               _Flags,
               _StrongNameKeyPair);
     name._HashForControl=_HashForControl;
     name._HashAlgorithmForControl=_HashAlgorithmForControl;
     return name;
 }
        [System.Security.SecurityCritical]  // auto-generated
        internal static AssemblyName GetAssemblyNameFromTypelib(Object typeLib, String asmFileName, byte[] publicKey, StrongNameKeyPair keyPair, Version asmVersion, AssemblyNameFlags asmNameFlags)
        {
            // Extract the name of the typelib.
            String strTypeLibName = null;
            String strDocString = null;
            int dwHelpContext = 0;
            String strHelpFile = null;
            ITypeLib pTLB = (ITypeLib)typeLib;
            pTLB.GetDocumentation(-1, out strTypeLibName, out strDocString, out dwHelpContext, out strHelpFile);

            // Retrieve the name to use for the assembly.
            if (asmFileName == null)
            {
                asmFileName = strTypeLibName;
            }
            else
            {
                Contract.Assert((asmFileName != null) && (asmFileName.Length > 0), "The assembly file name cannot be an empty string!");

                String strFileNameNoPath = Path.GetFileName(asmFileName);
                String strExtension = Path.GetExtension(asmFileName);

                // Validate that the extension is valid.
                bool bExtensionValid = ".dll".Equals(strExtension, StringComparison.OrdinalIgnoreCase);

                // If the extension is not valid then tell the user and quit.
                if (!bExtensionValid)
                    throw new ArgumentException(Environment.GetResourceString("Arg_InvalidFileExtension"));

                // The assembly cannot contain the path nor the extension.
                asmFileName = strFileNameNoPath.Substring(0, strFileNameNoPath.Length - ".dll".Length);
            }

            // If the version information was not specified, then retrieve it from the typelib.
            if (asmVersion == null)
            {
                int major;
                int minor;
                Marshal.GetTypeLibVersion(pTLB, out major, out minor);
                asmVersion = new Version(major, minor, 0, 0);
            }
            
            // Create the assembly name for the imported typelib's assembly.
            AssemblyName AsmName = new AssemblyName();
            AsmName.Init(
                asmFileName,
                publicKey,
                null,
                asmVersion,
                null,
                AssemblyHashAlgorithm.None,
                AssemblyVersionCompatibility.SameMachine,
                null,
                asmNameFlags,
                keyPair);

            return AsmName;
        }
Пример #12
0
        // If the assembly is copied before it is loaded, the codebase will be set to the
        // actual file loaded if fCopiedName is true. If it is false, then the original code base
        // is returned.
        /// <include file='doc\Assembly.uex' path='docs/doc[@for="Assembly.GetName1"]/*' />
        public virtual AssemblyName GetName(bool copiedName)
        {
            AssemblyName an = new AssemblyName();

            String codeBase = nGetCodeBase(copiedName, false);
            VerifyCodeBaseDiscovery(codeBase);

            an.Init(nGetSimpleName(), 
                    nGetPublicKey(),
                    null, // public key token
                    GetVersion(),
                    GetLocale(),
                    nGetHashAlgorithm(),
                    AssemblyVersionCompatibility.SameMachine,
                    codeBase,
                    nGetFlags() | AssemblyNameFlags.PublicKey,
                    null, // strong name key pair
                    this);

            return an;
        }
 public override AssemblyName GetName(bool copiedName)
 {
     AssemblyName name = new AssemblyName();
     string codeBase = this.GetCodeBase(copiedName);
     this.VerifyCodeBaseDiscovery(codeBase);
     name.Init(this.GetSimpleName(), this.GetPublicKey(), null, this.GetVersion(), this.GetLocale(), this.GetHashAlgorithm(), AssemblyVersionCompatibility.SameMachine, codeBase, this.GetFlags() | AssemblyNameFlags.PublicKey, null);
     Module manifestModule = this.ManifestModule;
     if ((manifestModule != null) && (manifestModule.MDStreamVersion > 0x10000))
     {
         PortableExecutableKinds kinds;
         ImageFileMachine machine;
         this.ManifestModule.GetPEKind(out kinds, out machine);
         name.SetProcArchIndex(kinds, machine);
     }
     return name;
 }
 internal static AssemblyName GetAssemblyNameFromTypelib(object typeLib, string asmFileName, byte[] publicKey, StrongNameKeyPair keyPair, Version asmVersion, AssemblyNameFlags asmNameFlags)
 {
     string strName = null;
     string strDocString = null;
     int dwHelpContext = 0;
     string strHelpFile = null;
     ITypeLib typeLibrary = (ITypeLib) typeLib;
     typeLibrary.GetDocumentation(-1, out strName, out strDocString, out dwHelpContext, out strHelpFile);
     if (asmFileName == null)
     {
         asmFileName = strName;
     }
     else
     {
         string fileName = Path.GetFileName(asmFileName);
         string extension = Path.GetExtension(asmFileName);
         if (!".dll".Equals(extension, StringComparison.OrdinalIgnoreCase))
         {
             throw new ArgumentException(Environment.GetResourceString("Arg_InvalidFileExtension"));
         }
         asmFileName = fileName.Substring(0, fileName.Length - ".dll".Length);
     }
     if (asmVersion == null)
     {
         int num2;
         int num3;
         Marshal.GetTypeLibVersion(typeLibrary, out num2, out num3);
         asmVersion = new Version(num2, num3, 0, 0);
     }
     AssemblyName name = new AssemblyName();
     name.Init(asmFileName, publicKey, null, asmVersion, null, AssemblyHashAlgorithm.None, AssemblyVersionCompatibility.SameMachine, null, asmNameFlags, keyPair);
     return name;
 }
Пример #15
0
 public virtual AssemblyName GetName(bool copiedName)
 {
     AssemblyName name = new AssemblyName();
     string codeBase = this.nGetCodeBase(copiedName);
     this.VerifyCodeBaseDiscovery(codeBase);
     name.Init(this.nGetSimpleName(), this.nGetPublicKey(), null, this.GetVersion(), this.GetLocale(), this.nGetHashAlgorithm(), AssemblyVersionCompatibility.SameMachine, codeBase, this.nGetFlags() | AssemblyNameFlags.PublicKey, null);
     name.ProcessorArchitecture = this.ComputeProcArchIndex();
     return name;
 }
 private void InitSafeToDeserializeArray()
 {
     this._safeToDeserialize = new bool[this._typeTable.Length];
     for (int i = 0; i < this._typeTable.Length; i++)
     {
         string str;
         AssemblyName name;
         string fullName;
         long position = this._store.BaseStream.Position;
         try
         {
             this._store.BaseStream.Position = this._typeNamePositions[i];
             str = this._store.ReadString();
         }
         finally
         {
             this._store.BaseStream.Position = position;
         }
         RuntimeType type = (RuntimeType) Type.GetType(str, false);
         if (type == null)
         {
             name = null;
             fullName = str;
         }
         else
         {
             if (type.BaseType == typeof(Enum))
             {
                 this._safeToDeserialize[i] = true;
                 continue;
             }
             fullName = type.FullName;
             name = new AssemblyName();
             RuntimeAssembly assembly = (RuntimeAssembly) type.Assembly;
             name.Init(assembly.GetSimpleName(), assembly.GetPublicKey(), null, null, assembly.GetLocale(), AssemblyHashAlgorithm.None, AssemblyVersionCompatibility.SameMachine, null, AssemblyNameFlags.PublicKey, null);
         }
         foreach (string str3 in TypesSafeForDeserialization)
         {
             if (ResourceManager.CompareNames(str3, fullName, name))
             {
                 this._safeToDeserialize[i] = true;
             }
         }
     }
 }