singrdk/base/Applications/Runtime/Full/System/Reflection/Assembly.cs

107 lines
3.3 KiB
C#
Raw Permalink Normal View History

2008-03-05 09:52:00 -05:00
// ==++==
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// ==--==
2008-11-17 18:29:00 -05:00
//=============================================================================
//
// Class: Assembly
//
// Purpose: For Assembly-related stuff.
//
//=============================================================================
namespace System.Reflection
{
2008-03-05 09:52:00 -05:00
using System;
using System.Runtime.CompilerServices;
//| <include path='docs/doc[@for="Assembly"]/*' />
2008-11-17 18:29:00 -05:00
public partial class Assembly
2008-03-05 09:52:00 -05:00
{
// ---------- Bartok code ----------
public AssemblyName Name
{
get {
return this.assemblyName;
}
}
internal String nGetSimpleName() {
return this.assemblyName.Name;
}
private String GetFullName() {
String name =
this.nGetSimpleName()
+ ", Version=" + this.assemblyName.Version.Major
+ "." + this.assemblyName.Version.Minor
+ "." + this.assemblyName.Version.Build
+ "." + this.assemblyName.Version.Revision
+ ", Culture="
+ (this.assemblyName.Culture != ""
? this.assemblyName.Culture
: "neutral")
+ ", PublicKeyToken="
+ (this.assemblyName.GetPublicKeyToken() != null
? (Assembly.EncodeHexString
(this.assemblyName.GetPublicKeyToken()))
: "null");
return name;
}
// ---------- copied from mscorlib System.Security.Util.Hex ----------
// changed to lowercase to avoid ToLower call since the code is no
// longer shared in Util.Hex
private static char[] hexValues =
{ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
'a', 'b', 'c', 'd', 'e', 'f' };
private static String EncodeHexString(byte[] sArray)
{
String result = null;
2008-11-17 18:29:00 -05:00
if (sArray != null) {
2008-03-05 09:52:00 -05:00
char[] hexOrder = new char[sArray.Length * 2];
int digit;
2008-11-17 18:29:00 -05:00
for (int i = 0, j = 0; i < sArray.Length; i++) {
2008-03-05 09:52:00 -05:00
digit = (int)((sArray[i] & 0xf0) >> 4);
hexOrder[j++] = hexValues[digit];
digit = (int)(sArray[i] & 0x0f);
hexOrder[j++] = hexValues[digit];
}
result = new String(hexOrder);
}
return result;
}
// ---------- mscorlib code ----------
// (some modifications to pull in less code)
//| <include path='docs/doc[@for="Assembly.FullName"]/*' />
public virtual String FullName {
get {
// If called by Object.ToString(), return val may be NULL.
String s;
2008-11-17 18:29:00 -05:00
// not implementing InternalCache for now
//if ((s = (String)Cache[CacheObjType.AssemblyName]) != null)
// return s;
//
2008-03-05 09:52:00 -05:00
s = GetFullName();
2008-11-17 18:29:00 -05:00
// not implementing InternalCache for now
//if (s != null)
// Cache[CacheObjType.AssemblyName] = s;
//
2008-03-05 09:52:00 -05:00
return s;
}
}
}
}