当前位置: 首页>>代码示例>>C#>>正文


C# AssemblyName.Init方法代码示例

本文整理汇总了C#中System.Reflection.AssemblyName.Init方法的典型用法代码示例。如果您正苦于以下问题:C# AssemblyName.Init方法的具体用法?C# AssemblyName.Init怎么用?C# AssemblyName.Init使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Reflection.AssemblyName的用法示例。


在下文中一共展示了AssemblyName.Init方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Clone

 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;
 }
开发者ID:randomize,项目名称:VimConfig,代码行数:8,代码来源:AssemblyName.cs

示例2: InitSafeToDeserializeArray

        [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
            }
        }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:67,代码来源:resourcereader.cs

示例3: GetName

        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;
        }
开发者ID:afrog33k,项目名称:csnative,代码行数:32,代码来源:Assembly.cs

示例4: Clone

 // 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;
 }
开发者ID:AtsushiKan,项目名称:coreclr,代码行数:18,代码来源:AssemblyName.cs

示例5: GetAssemblyNameFromTypelib

        [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;
        }
开发者ID:Rayislandstyle,项目名称:dotnet-coreclr,代码行数:59,代码来源:TypeLibConverter.cs

示例6: GetName

        // 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;
        }
开发者ID:ArildF,项目名称:masters,代码行数:25,代码来源:assembly.cs

示例7: GetName

 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;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:16,代码来源:RuntimeAssembly.cs

示例8: GetAssemblyNameFromTypelib

 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;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:33,代码来源:TypeLibConverter.cs

示例9: GetName

 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;
 }
开发者ID:randomize,项目名称:VimConfig,代码行数:9,代码来源:Assembly.cs

示例10: InitSafeToDeserializeArray

 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;
             }
         }
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:45,代码来源:ResourceReader.cs


注:本文中的System.Reflection.AssemblyName.Init方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。