(DISTFILES): Comment out a few missing files.
[mono-project.git] / mcs / class / corlib / System / ApplicationId.cs
blob5be7c4b52eae4f159f4eae3713912d2925776da8
1 //
2 // System.ApplicationId class
3 //
4 // Author:
5 // Sebastien Pouliot <sebastien@ximian.com>
6 //
7 // Copyright (C) 2004 Novell, Inc (http://www.novell.com)
8 //
9 // Permission is hereby granted, free of charge, to any person obtaining
10 // a copy of this software and associated documentation files (the
11 // "Software"), to deal in the Software without restriction, including
12 // without limitation the rights to use, copy, modify, merge, publish,
13 // distribute, sublicense, and/or sell copies of the Software, and to
14 // permit persons to whom the Software is furnished to do so, subject to
15 // the following conditions:
16 //
17 // The above copyright notice and this permission notice shall be
18 // included in all copies or substantial portions of the Software.
19 //
20 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
24 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
25 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
26 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 #if NET_2_0
31 using System.Text;
33 namespace System {
35 [Serializable]
36 public sealed class ApplicationId {
38 private byte[] _token;
39 private string _name;
40 private Version _version;
41 private string _proc;
42 private string _culture;
44 public ApplicationId (byte[] publicKeyToken, string name, Version version, string processorArchitecture, string culture)
46 if (publicKeyToken == null)
47 throw new ArgumentNullException ("publicKeyToken");
48 if (name == null)
49 throw new ArgumentNullException ("name");
50 if (version == null)
51 throw new ArgumentNullException ("version");
53 _token = (byte[]) publicKeyToken.Clone ();
54 _name = name;
55 _version = version;
56 _proc = processorArchitecture;
57 _culture = culture;
60 // properties
62 public string Culture {
63 get { return _culture; }
66 public string Name {
67 get { return _name; }
70 public string ProcessorArchitecture {
71 get { return _proc; }
74 public byte[] PublicKeyToken {
75 get { return (byte[]) _token.Clone (); }
78 public Version Version {
79 get { return _version; }
82 // methods
84 public ApplicationId Copy ()
86 return new ApplicationId (_token, _name, _version, _proc, _culture);
89 public override bool Equals (object o)
91 if (o == null)
92 return false;
93 ApplicationId appid = (o as ApplicationId);
94 if (appid == null)
95 return false;
96 if (_name != appid._name)
97 return false;
98 if (_proc != appid._proc)
99 return false;
100 if (_culture != appid._culture)
101 return false;
102 if (!_version.Equals (appid._version))
103 return false;
104 if (_token.Length != appid._token.Length)
105 return false;
106 for (int i=0; i < _token.Length; i++)
107 if (_token [i] != appid._token [i])
108 return false;
109 return true;
112 public override int GetHashCode ()
114 int code = _name.GetHashCode () ^ _version.GetHashCode ();
115 for (int i=0; i < _token.Length; i++)
116 code ^= _token [i];
117 // ProcessorArchitecture and Culture aren't part of the hash code
118 // Confirmed by Microsoft in FDBK13339
119 return code;
122 public override string ToString ()
124 StringBuilder sb = new StringBuilder ();
125 sb.Append (_name);
126 if (_culture != null)
127 sb.AppendFormat (", culture=\"{0}\"", _culture);
128 sb.AppendFormat (", version=\"{0}\", publicKeyToken=\"", _version);
129 for (int i=0; i < _token.Length; i++)
130 sb.Append (_token [i].ToString ("X2"));
131 if (_proc != null)
132 sb.AppendFormat ("\", processorArchitecture =\"{0}\"", _proc);
133 else
134 sb.Append ("\"");
135 return sb.ToString ();
140 #endif