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


C# Reflection.StrongNameKeyPair类代码示例

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


StrongNameKeyPair类属于System.Reflection命名空间,在下文中一共展示了StrongNameKeyPair类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Update

 public void Update( StrongNameKeyPair snk, HashSet<IAssemblyInfo> notSigned, IEnumerable<IAssemblyInfo> allAssemblies )
 {
     foreach( var assemblyInfo in notSigned )
     {
         UpdateAttributesInAssembly( snk, assemblyInfo.Assembly );
     }
 }
开发者ID:rjasica,项目名称:sign,代码行数:7,代码来源:UpdateTypeAttributeArguments.cs

示例2: StrongName

		public static void StrongName (Stream stream, ImageWriter writer, StrongNameKeyPair key_pair)
		{
			int strong_name_pointer;

			var strong_name = CreateStrongName (key_pair, HashStream (stream, writer, out strong_name_pointer));
			PatchStrongName (stream, strong_name_pointer, strong_name);
		}
开发者ID:yayanyang,项目名称:monodevelop,代码行数:7,代码来源:CryptoService.cs

示例3: StrongNameKeyPairNegTest

        public void StrongNameKeyPairNegTest()
        {
            var sKeyPair = new StrongNameKeyPair(s_data);

            Assert.Throws<PlatformNotSupportedException>(() => sKeyPair.PublicKey);
            Assert.Throws<PlatformNotSupportedException>(() => new StrongNameKeyPair("Hello World"));
        }
开发者ID:dotnet,项目名称:corefx,代码行数:7,代码来源:StrongNameKeyPairTests.netstandard1.7.cs

示例4: MigrationContext

 public MigrationContext(
     MigrationSettings settings,
     OrmPackage package,
     PortalApplication portal,
     BundleManifest manifest,
     IVSProject vsProject,
     CodeDomProvider codeProvider,
     StrongNameKeyPair keyPair,
     IExtendedLog log,
     IOperationStatus status,
     ICollection<Plugin> plugins)
 {
     _settings = settings;
     _package = package;
     _portal = portal;
     _manifest = manifest;
     _vsProject = vsProject;
     _codeProvider = codeProvider;
     _keyPair = keyPair;
     _log = log;
     _status = status;
     _plugins = plugins;
     _forms = new Dictionary<string, FormInfo>(StringComparer.InvariantCultureIgnoreCase);
     _mainViews = new Dictionary<string, MainViewInfo>(StringComparer.InvariantCultureIgnoreCase);
     _navigation = new List<NavigationInfo>();
     _scripts = new Dictionary<string, ScriptInfo>(StringComparer.InvariantCultureIgnoreCase);
     _tables = new Dictionary<string, TableInfo>(StringComparer.InvariantCultureIgnoreCase);
     _entities = new Dictionary<string, OrmEntity>(StringComparer.InvariantCultureIgnoreCase);
     _relationships = new Dictionary<DataPathJoin, RelationshipInfo>();
     _linkedFiles = new List<LinkedFile>();
     _localizedStrings = new Dictionary<string, string>(StringComparer.InvariantCultureIgnoreCase);
     _references = new Dictionary<string, string>(StringComparer.InvariantCultureIgnoreCase);
     _smartParts = new List<SmartPartMapping>();
     _secondaryJoins = new Dictionary<DataPathJoin, DataPathJoin>();
 }
开发者ID:Saleslogix,项目名称:SLXMigration,代码行数:35,代码来源:MigrationContext.cs

示例5: Perform

        public void Perform()
        {
            if (_repackOptions.KeyFile != null && File.Exists(_repackOptions.KeyFile))
            {
                var snkp = default(StrongNameKeyPair);
                var publicKey = default(byte[]);

                var keyFileContent = File.ReadAllBytes(_repackOptions.KeyFile);
                try
                {
                    snkp = new StrongNameKeyPair(keyFileContent);
                    publicKey = snkp.PublicKey;
                }
                catch (ArgumentException)
                {
                    snkp = null;
                    publicKey = keyFileContent;
                }

                _repackContext.TargetAssemblyDefinition.Name.PublicKey = publicKey;
                _repackContext.TargetAssemblyDefinition.Name.Attributes |= AssemblyAttributes.PublicKey;
                _repackContext.TargetAssemblyMainModule.Attributes |= ModuleAttributes.StrongNameSigned;
                if (!_repackOptions.DelaySign)
                    KeyPair = snkp;
            }
            else
            {
                _repackContext.TargetAssemblyDefinition.Name.PublicKey = null;
                _repackContext.TargetAssemblyMainModule.Attributes &= ~ModuleAttributes.StrongNameSigned;
            }
        }
开发者ID:jm3105,项目名称:il-repack,代码行数:31,代码来源:SigningStep.cs

示例6: UpdateAttribute

        private void UpdateAttribute(StrongNameKeyPair snk, AssemblyDefinition assemby)
        {
            foreach (var type in assemby.MainModule.GetTypes().Where(t => t.HasCustomAttributes))
            {
                foreach (var knownTypeAttribute in type.CustomAttributes.Where(t => t.AttributeType.FullName == KnowTypeAttributeName))
                {
                    if (knownTypeAttribute == null)
                    {
                        continue;
                    }

                    var argument = knownTypeAttribute.ConstructorArguments.FirstOrDefault(t => t.Type.FullName == TypeFullName);

                    if (argument.Type == null || argument.Value == null)
                    {
                        continue;
                    }

                    var typeReference = argument.Value as TypeReference;
                    if (typeReference == null)
                    {
                        continue;
                    }

                    var assemblyReference = typeReference.Scope as AssemblyNameReference;
                    if (assemblyReference == null)
                    {
                        continue;
                    }

                    assemblyReference.PublicKey = snk.PublicKey;
                }
            }
        }
开发者ID:rjasica,项目名称:sign,代码行数:34,代码来源:UpdateKnowTypeAttribute.cs

示例7: WriteModifiedAssemblies

 private static void WriteModifiedAssemblies( StrongNameKeyPair snk, IEnumerable<IAssemblyInfo> notSigned )
 {
     foreach( var assemblyInfo in notSigned )
     {
         assemblyInfo.Assembly.Write( assemblyInfo.FullPath, new WriterParameters { StrongNameKeyPair = snk } );
     }
 }
开发者ID:rjasica,项目名称:sign,代码行数:7,代码来源:Signer.cs

示例8: BaseTypeImporter

 protected BaseTypeImporter(string outputDirectory, StrongNameKeyPair keyPair, IDictionary<string, string> importedFileNames)
 {
     _outputDirectory = outputDirectory;
     _keyPair = keyPair;
     _importedFileNames = importedFileNames;
     _loadedAssemblies = new Dictionary<string, Assembly>();
     _cachedTypes = new Dictionary<string, Type>();
 }
开发者ID:Saleslogix,项目名称:SLXMigration,代码行数:8,代码来源:BaseTypeImporter.cs

示例9: NotImplementedException

	// Convert a type library into an emitted assembly.
	public AssemblyBuilder ConvertTypeLibToAssembly
				(Object typeLib, String asmFileName,
				 int flags, ITypeLibImporterNotifySink notifySink,
				 byte[] publicKey, StrongNameKeyPair keyPair,
				 bool unsafeInterfaces)
			{
				throw new NotImplementedException();
			}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:9,代码来源:TypeLibConverter.cs

示例10: GetPublicKeyFromKeyFile

 public static byte[] GetPublicKeyFromKeyFile(string keyFile)
 {
     StrongNameKeyPair sn = null;
     using (FileStream fs = new FileStream(keyFile, FileMode.Open, FileAccess.Read))
     {
         sn = new StrongNameKeyPair(fs);
         return sn.PublicKey;
     }
 }
开发者ID:adisik,项目名称:simple-assembly-explorer,代码行数:9,代码来源:TokenUtils.cs

示例11: Update

 public void Update(
     StrongNameKeyPair snk,
     HashSet<IAssemblyInfo> notSigned,
     IEnumerable<IAssemblyInfo> allAssemblies)
 {
     foreach( var assemblyInfo in notSigned.ToArray() )
     {
         UpdateAssembly( notSigned, assemblyInfo );
     }
 }
开发者ID:rjasica,项目名称:sign,代码行数:10,代码来源:UpdateInternalVisibleToAttribute.cs

示例12: WriteAssembly

        static void WriteAssembly( AssemblyDefinition assembly, string targetPath, StrongNameKeyPair snk )
        {
            WriterParameters wp = new WriterParameters()
            {
                WriteSymbols = true,
                StrongNameKeyPair = snk
            };

            assembly.Write( targetPath, wp );
        }
开发者ID:InishTech,项目名称:ExtensionAttributeStripper,代码行数:10,代码来源:Program.cs

示例13: ConvertTypeLibToAssembly

 public AssemblyBuilder ConvertTypeLibToAssembly([MarshalAs(UnmanagedType.Interface)] object typeLib, string asmFileName, TypeLibImporterFlags flags, ITypeLibImporterNotifySink notifySink, byte[] publicKey, StrongNameKeyPair keyPair, string asmNamespace, Version asmVersion)
 {
     if (typeLib == null)
     {
         throw new ArgumentNullException("typeLib");
     }
     if (asmFileName == null)
     {
         throw new ArgumentNullException("asmFileName");
     }
     if (notifySink == null)
     {
         throw new ArgumentNullException("notifySink");
     }
     if (string.Empty.Equals(asmFileName))
     {
         throw new ArgumentException(Environment.GetResourceString("Arg_InvalidFileName"), "asmFileName");
     }
     if (asmFileName.Length > 260)
     {
         throw new ArgumentException(Environment.GetResourceString("IO.PathTooLong"), asmFileName);
     }
     if ((((flags & TypeLibImporterFlags.PrimaryInteropAssembly) != TypeLibImporterFlags.None) && (publicKey == null)) && (keyPair == null))
     {
         throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_PIAMustBeStrongNamed"));
     }
     ArrayList eventItfInfoList = null;
     AssemblyNameFlags none = AssemblyNameFlags.None;
     AssemblyName asmName = GetAssemblyNameFromTypelib(typeLib, asmFileName, publicKey, keyPair, asmVersion, none);
     AssemblyBuilder asmBldr = CreateAssemblyForTypeLib(typeLib, asmFileName, asmName, (flags & TypeLibImporterFlags.PrimaryInteropAssembly) != TypeLibImporterFlags.None, (flags & TypeLibImporterFlags.ReflectionOnlyLoading) != TypeLibImporterFlags.None, (flags & TypeLibImporterFlags.NoDefineVersionResource) != TypeLibImporterFlags.None);
     string fileName = Path.GetFileName(asmFileName);
     ModuleBuilder mod = asmBldr.DefineDynamicModule(fileName, fileName);
     if (asmNamespace == null)
     {
         asmNamespace = asmName.Name;
     }
     TypeResolveHandler handler = new TypeResolveHandler(mod, notifySink);
     AppDomain domain = Thread.GetDomain();
     ResolveEventHandler handler2 = new ResolveEventHandler(handler.ResolveEvent);
     ResolveEventHandler handler3 = new ResolveEventHandler(handler.ResolveAsmEvent);
     ResolveEventHandler handler4 = new ResolveEventHandler(handler.ResolveROAsmEvent);
     domain.TypeResolve += handler2;
     domain.AssemblyResolve += handler3;
     domain.ReflectionOnlyAssemblyResolve += handler4;
     nConvertTypeLibToMetadata(typeLib, asmBldr.InternalAssembly, mod.InternalModule, asmNamespace, flags, handler, out eventItfInfoList);
     UpdateComTypesInAssembly(asmBldr, mod);
     if (eventItfInfoList.Count > 0)
     {
         new TCEAdapterGenerator().Process(mod, eventItfInfoList);
     }
     domain.TypeResolve -= handler2;
     domain.AssemblyResolve -= handler3;
     domain.ReflectionOnlyAssemblyResolve -= handler4;
     return asmBldr;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:55,代码来源:TypeLibConverter.cs

示例14: Run

        public int Run(String               strTypeLibName,
            String               strAssemblyName,
            String               strAssemblyNamespace,
            String               strOutputDir,
            byte[]               aPublicKey,
            StrongNameKeyPair    sKeyPair,
            String               strAssemblyRefList,
            String               strTypeLibRefList,
            Version              AssemblyVersion,
            TypeLibImporterFlags flags,
            bool                 bNoLogo,
            bool                 bSilentMode,
            System.Collections.Generic.List<int> silenceList,
            bool                 bVerboseMode,
            bool                 bStrictRef,
            bool                 bStrictRefNoPia,
            bool                 bSearchPathSucceeded,
            String               strProduct,
            String               strProductVersion,
            String               strCompany,
            String               strCopyright,
            String               strTrademark,
            bool                 isVersion2,
            bool                 isPreserveSig,
            String               ruleSetFileName)
        {
            TlbImpOptions options = new TlbImpOptions();
            options.m_strTypeLibName = strTypeLibName;
            options.m_strAssemblyName = strAssemblyName;
            options.m_strAssemblyNamespace = strAssemblyNamespace;
            options.m_strOutputDir = strOutputDir;
            options.m_aPublicKey = aPublicKey;
            options.m_sKeyPair = sKeyPair;
            options.m_strAssemblyRefList = strAssemblyRefList;
            options.m_strTypeLibRefList = strTypeLibRefList;
            options.m_AssemblyVersion = AssemblyVersion;
            options.m_flags = flags;
            options.m_bNoLogo = bNoLogo;
            options.m_bSilentMode = bSilentMode;
            options.m_silenceList = silenceList;
            options.m_bVerboseMode = bVerboseMode;
            options.m_bStrictRef = bStrictRef;
            options.m_bStrictRefNoPia = bStrictRefNoPia;
            options.m_bSearchPathSucceeded = bSearchPathSucceeded;
            options.m_strProduct = strProduct;
            options.m_strProductVersion = strProductVersion;
            options.m_strCompany = strCompany;
            options.m_strCopyright = strCopyright;
            options.m_strTrademark = strTrademark;
            options.m_isVersion2 = isVersion2;
            options.m_isPreserveSig = isPreserveSig;
            options.m_ruleSetFileName = ruleSetFileName;

            return TlbImpCode.Run(options);
        }
开发者ID:dbremner,项目名称:clrinterop,代码行数:55,代码来源:RemoteTlbImp.cs

示例15: ReadKeyFile

        /// <summary>
        /// Reads contents of a key file. Reused from vsdesigner code.
        /// </summary>
        /// <param name="log"></param>
        /// <param name="keyFile"></param>
        /// <param name="keyPair"></param>
        /// <param name="publicKey"></param>
        internal static void ReadKeyFile(TaskLoggingHelper log, string keyFile, out StrongNameKeyPair keyPair, out byte[] publicKey)
        {
            // Initialize parameters
            keyPair = null;
            publicKey = null;

            byte[] keyFileContents;

            try
            {
                // Read the stuff from the file stream
                using (FileStream fs = new FileStream(keyFile, FileMode.Open, FileAccess.Read, FileShare.Read))
                {
                    keyFileContents = new byte[(int)fs.Length];
                    fs.Read(keyFileContents, 0, (int)fs.Length);
                }
            }
            catch (ArgumentException e)
            {
                log.LogErrorWithCodeFromResources("StrongNameUtils.KeyFileReadFailure", keyFile);
                log.LogErrorFromException(e);
                throw new StrongNameException(e);
            }
            catch (IOException e)
            {
                log.LogErrorWithCodeFromResources("StrongNameUtils.KeyFileReadFailure", keyFile);
                log.LogErrorFromException(e);
                throw new StrongNameException(e);
            }
            catch (SecurityException e)
            {
                log.LogErrorWithCodeFromResources("StrongNameUtils.KeyFileReadFailure", keyFile);
                log.LogErrorFromException(e);
                throw new StrongNameException(e);
            }

            // Make a new key pair from what we read
            StrongNameKeyPair snp = new StrongNameKeyPair(keyFileContents);

            // If anything fails reading the public key portion of the strong name key pair, then
            // assume that keyFile contained only the public key portion of the public/private pair.
            try
            {
                publicKey = snp.PublicKey;

                // If we didn't throw up to this point then we have a valid public/private key pair,
                // so assign the object just created above to the out parameter.  
                keyPair = snp;
            }
            catch (ArgumentException)
            {
                publicKey = keyFileContents;
            }
        }
开发者ID:JamesLinus,项目名称:msbuild,代码行数:61,代码来源:StrongNameUtils.cs


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