本文整理汇总了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;
}
示例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;
}
示例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);
}
示例4: SetPublicKey_GetPublicKey
public void SetPublicKey_GetPublicKey(byte[] publicKey)
{
AssemblyName assemblyName = new AssemblyName();
assemblyName.SetPublicKey(publicKey);
Assert.Equal(publicKey, assemblyName.GetPublicKey());
}
示例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;
}
}
示例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
}