mscorlib(4.0.0.0) API with additions
ApplicationId.cs
2 using System.Security.Util;
3 using System.Text;
4 
5 namespace System
6 {
9  [ComVisible(true)]
10  public sealed class ApplicationId
11  {
12  private string m_name;
13 
14  private Version m_version;
15 
16  private string m_processorArchitecture;
17 
18  private string m_culture;
19 
20  internal byte[] m_publicKeyToken;
21 
24  public byte[] PublicKeyToken
25  {
26  get
27  {
28  byte[] array = new byte[m_publicKeyToken.Length];
29  Array.Copy(m_publicKeyToken, 0, array, 0, m_publicKeyToken.Length);
30  return array;
31  }
32  }
33 
36  public string Name => m_name;
37 
40  public Version Version => m_version;
41 
44  public string ProcessorArchitecture => m_processorArchitecture;
45 
48  public string Culture => m_culture;
49 
50  internal ApplicationId()
51  {
52  }
53 
66  public ApplicationId(byte[] publicKeyToken, string name, Version version, string processorArchitecture, string culture)
67  {
68  if (name == null)
69  {
70  throw new ArgumentNullException("name");
71  }
72  if (name.Length == 0)
73  {
74  throw new ArgumentException(Environment.GetResourceString("Argument_EmptyApplicationName"));
75  }
76  if (version == null)
77  {
78  throw new ArgumentNullException("version");
79  }
80  if (publicKeyToken == null)
81  {
82  throw new ArgumentNullException("publicKeyToken");
83  }
84  m_publicKeyToken = new byte[publicKeyToken.Length];
85  Array.Copy(publicKeyToken, 0, m_publicKeyToken, 0, publicKeyToken.Length);
86  m_name = name;
87  m_version = version;
88  m_processorArchitecture = processorArchitecture;
89  m_culture = culture;
90  }
91 
95  {
96  return new ApplicationId(m_publicKeyToken, m_name, m_version, m_processorArchitecture, m_culture);
97  }
98 
101  public override string ToString()
102  {
103  StringBuilder stringBuilder = StringBuilderCache.Acquire();
104  stringBuilder.Append(m_name);
105  if (m_culture != null)
106  {
107  stringBuilder.Append(", culture=\"");
108  stringBuilder.Append(m_culture);
109  stringBuilder.Append("\"");
110  }
111  stringBuilder.Append(", version=\"");
112  stringBuilder.Append(m_version.ToString());
113  stringBuilder.Append("\"");
114  if (m_publicKeyToken != null)
115  {
116  stringBuilder.Append(", publicKeyToken=\"");
117  stringBuilder.Append(Hex.EncodeHexString(m_publicKeyToken));
118  stringBuilder.Append("\"");
119  }
120  if (m_processorArchitecture != null)
121  {
122  stringBuilder.Append(", processorArchitecture =\"");
123  stringBuilder.Append(m_processorArchitecture);
124  stringBuilder.Append("\"");
125  }
126  return StringBuilderCache.GetStringAndRelease(stringBuilder);
127  }
128 
133  public override bool Equals(object o)
134  {
135  ApplicationId applicationId = o as ApplicationId;
136  if (applicationId == null)
137  {
138  return false;
139  }
140  if (!object.Equals(m_name, applicationId.m_name) || !object.Equals(m_version, applicationId.m_version) || !object.Equals(m_processorArchitecture, applicationId.m_processorArchitecture) || !object.Equals(m_culture, applicationId.m_culture))
141  {
142  return false;
143  }
144  if (m_publicKeyToken.Length != applicationId.m_publicKeyToken.Length)
145  {
146  return false;
147  }
148  for (int i = 0; i < m_publicKeyToken.Length; i++)
149  {
150  if (m_publicKeyToken[i] != applicationId.m_publicKeyToken[i])
151  {
152  return false;
153  }
154  }
155  return true;
156  }
157 
160  public override int GetHashCode()
161  {
162  return m_name.GetHashCode() ^ m_version.GetHashCode();
163  }
164  }
165 }
override int GetHashCode()
Returns a hash code for the current T:System.Version object.
Definition: Version.cs:425
The exception that is thrown when a null reference (Nothing in Visual Basic) is passed to a method th...
string Culture
Gets a string representing the culture information for the application.
ApplicationId Copy()
Creates and returns an identical copy of the current application identity.
Definition: __Canon.cs:3
override string ToString()
Converts the value of the current T:System.Version object to its equivalent T:System....
Definition: Version.cs:437
Provides information about, and means to manipulate, the current environment and platform....
Definition: Environment.cs:21
StringBuilder Append(char value, int repeatCount)
Appends a specified number of copies of the string representation of a Unicode character to this inst...
Provides methods for creating, manipulating, searching, and sorting arrays, thereby serving as the ba...
Definition: Array.cs:17
Represents the version number of an assembly, operating system, or the common language runtime....
Definition: Version.cs:11
override string ToString()
Creates and returns a string representation of the application identity.
Represents a mutable string of characters. This class cannot be inherited.To browse the ....
The exception that is thrown when one of the arguments provided to a method is not valid.
static void Copy(Array sourceArray, Array destinationArray, int length)
Copies a range of elements from an T:System.Array starting at the first element and pastes them into ...
Definition: Array.cs:1275
override bool Equals(object o)
Determines whether the specified T:System.ApplicationId object is equivalent to the current T:System....
string Name
Gets the name of the application.
Specifies that the class can be serialized.
ApplicationId(byte[] publicKeyToken, string name, Version version, string processorArchitecture, string culture)
Initializes a new instance of the T:System.ApplicationId class.
Contains information used to uniquely identify a manifest-based application. This class cannot be inh...
override int GetHashCode()
Gets the hash code for the current application identity.
string ProcessorArchitecture
Gets the target processor architecture for the application.
byte [] PublicKeyToken
Gets the public key token for the application.