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


C# AssemblyName.GetPublicKey方法代码示例

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


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

示例1: PosTest1

 public bool PosTest1()
 {
     TestLibrary.TestFramework.BeginScenario("PosTest1: get default PublicKey");
     bool retVal = true;
     try
     {
         AssemblyName an = new AssemblyName();
         byte[] key = an.GetPublicKey();
         if (key != null)
         {
             TestLibrary.TestFramework.LogError("001.1", "expect (new AssemblyName()).GetPublicKey() == null");
             retVal = false;
         }
     }
     catch (Exception e)
     {
         TestLibrary.TestFramework.LogError("001.2", "Unexpected exception: " + e);
         retVal = false;
     }
     return retVal;
 }
开发者ID:l1183479157,项目名称:coreclr,代码行数:21,代码来源:assemblynamegetpublickey.cs

示例2: PosTest2

    public bool PosTest2()
    {
        TestLibrary.TestFramework.BeginScenario("PosTest2: set a 0 length key then get and verify");
        bool retVal = true;
        try
        {
            byte[] key = new byte[0];

            AssemblyName an = new AssemblyName();
            an.SetPublicKey(key);

            if (an.GetPublicKey() != key)
            {
                TestLibrary.TestFramework.LogError("002.1", "expect AssemblyName.GetPublicKey() equals what it's been set");
                retVal = false;
            }
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("002.2", "Unexpected exception: " + e);
            retVal = false;
        }
        return retVal;
    }
开发者ID:l1183479157,项目名称:coreclr,代码行数:24,代码来源:assemblynamesetpublickey.cs

示例3: AssemblyBuilder

		internal AssemblyBuilder(Universe universe, AssemblyName name, string dir, IEnumerable<CustomAttributeBuilder> customAttributes)
			: base(universe)
		{
			this.name = name.Name;
			SetVersionHelper(name.Version);
			if (!string.IsNullOrEmpty(name.Culture))
			{
				this.culture = name.Culture;
			}
			this.flags = name.RawFlags;
			this.hashAlgorithm = name.HashAlgorithm;
			if (this.hashAlgorithm == AssemblyHashAlgorithm.None)
			{
				this.hashAlgorithm = AssemblyHashAlgorithm.SHA1;
			}
			this.keyPair = name.KeyPair;
			if (this.keyPair != null)
			{
				this.publicKey = this.keyPair.PublicKey;
			}
			else
			{
				byte[] publicKey = name.GetPublicKey();
				if (publicKey != null && publicKey.Length != 0)
				{
					this.publicKey = (byte[])publicKey.Clone();
				}
			}
			this.dir = dir ?? ".";
			if (customAttributes != null)
			{
				this.customAttributes.AddRange(customAttributes);
			}
			if (universe.HasMscorlib && !universe.Mscorlib.__IsMissing && universe.Mscorlib.ImageRuntimeVersion != null)
			{
				this.imageRuntimeVersion = universe.Mscorlib.ImageRuntimeVersion;
			}
			else
			{
				this.imageRuntimeVersion = typeof(object).Assembly.ImageRuntimeVersion;
			}
			universe.RegisterDynamicAssembly(this);
		}
开发者ID:Semogj,项目名称:ikvm-fork,代码行数:43,代码来源:AssemblyBuilder.cs

示例4: SetPublicKey_GetPublicKey

 public void SetPublicKey_GetPublicKey(byte[] publicKey)
 {
     AssemblyName assemblyName = new AssemblyName();
     assemblyName.SetPublicKey(publicKey);
     Assert.Equal(publicKey, assemblyName.GetPublicKey());
 }
开发者ID:dotnet,项目名称:corefx,代码行数:6,代码来源:AssemblyNameTests.cs

示例5: AssemblyBuilder

		internal AssemblyBuilder(Universe universe, AssemblyName name, string dir, PermissionSet requiredPermissions, PermissionSet optionalPermissions, PermissionSet refusedPermissions)
			: base(universe)
		{
			this.name = name.Name;
			SetVersionHelper(name.Version);
			if (!string.IsNullOrEmpty(name.Culture))
			{
				this.culture = name.Culture;
			}
			this.flags = name.RawFlags;
			this.hashAlgorithm = name.HashAlgorithm;
			if (this.hashAlgorithm == AssemblyHashAlgorithm.None)
			{
				this.hashAlgorithm = AssemblyHashAlgorithm.SHA1;
			}
			this.keyPair = name.KeyPair;
			if (this.keyPair != null)
			{
				this.publicKey = this.keyPair.PublicKey;
			}
			else
			{
				byte[] publicKey = name.GetPublicKey();
				if (publicKey != null && publicKey.Length != 0)
				{
					this.publicKey = (byte[])publicKey.Clone();
				}
			}
			this.dir = dir ?? ".";
			this.requiredPermissions = requiredPermissions;
			this.optionalPermissions = optionalPermissions;
			this.refusedPermissions = refusedPermissions;
			if (universe.HasMscorlib && !universe.Mscorlib.__IsMissing && universe.Mscorlib.ImageRuntimeVersion != null)
			{
				this.imageRuntimeVersion = universe.Mscorlib.ImageRuntimeVersion;
			}
			else
			{
				this.imageRuntimeVersion = typeof(object).Assembly.ImageRuntimeVersion;
			}
		}
开发者ID:robert-j,项目名称:mono-fork,代码行数:41,代码来源:AssemblyBuilder.cs

示例6: PrintAssemblyName

    void PrintAssemblyName(Assembly asm, AssemblyName asmName, bool IsExtern)
    {
        if (asmName == null) throw new ArgumentNullException(nameof(asmName));
        if (IsExtern)
            sw.WriteLine(".assembly extern " + asmName.Name);
        else sw.WriteLine(".assembly " + asmName.Name);
        sw.WriteLine("{");
        // we don't care the referenced assembly version here in order to make the program stronger
        sw.WriteLine(".ver |");
        sw.WriteLine(".hash " + asmName.HashAlgorithm);
        sw.WriteLine(".culture " + ((asmName.CultureInfo != null) ? "NULL" : asmName.CultureInfo.ToString())); // for null we just print nothing
        sw.WriteLine(".versionCompatibility " + asmName.VersionCompatibility);
        if (asmName.KeyPair != null)
            sw.WriteLine(".keypair " + BytesToString(asmName.KeyPair.PublicKey));
        sw.WriteLine(".publickey " + BytesToString(asmName.GetPublicKey()));
        if (asmName.GetPublicKeyToken() != null)
            sw.WriteLine(".publickeytoken " + BytesToString(asmName.GetPublicKeyToken()));

        // print out assembly name flags
        string s = null;
        // add back in orcas
        /*if ((asmName.Flags & AssemblyNameFlags.Library) != 0)
            s = "Library";
        else if ((asmName.Flags & AssemblyNameFlags.AppDomainPlatform) != 0)
            s = "AppDomainPlatform";
        else if ((asmName.Flags & AssemblyNameFlags.ProcessPlatform) != 0)
            s = "ProcessPlatform";
        else if ((asmName.Flags & AssemblyNameFlags.SystemPlatform) != 0)
            s = "SystemPlatform";*/
        sw.WriteLine(".flags " + s);

        if (!IsExtern)
        {
            PrintCustomAttributes(CustomAttributeData.GetCustomAttributes(asm));
        }
        sw.WriteLine("} // end of assembly");
        // We don't care codebase
    }
开发者ID:dbremner,项目名称:clrinterop,代码行数:38,代码来源:AssemPrinter.cs


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