[runtime] Updates comments.
[mono.git] / mcs / class / corlib / System.Globalization / CultureNotFoundException.cs
1 //
2 // System.Globalization.CultureNotFoundException.cs
3 //
4 // Authors:
5 //      Gonzalo Paniagua Javier (gonzalo@novell.com)
6 //
7 // Copyright (c) 2010 Novell (http://www.novell.com)
8 //
9
10 // Permission is hereby granted, free of charge, to any person obtaining
11 // a copy of this software and associated documentation files (the
12 // "Software"), to deal in the Software without restriction, including
13 // without limitation the rights to use, copy, modify, merge, publish,
14 // distribute, sublicense, and/or sell copies of the Software, and to
15 // permit persons to whom the Software is furnished to do so, subject to
16 // the following conditions:
17 // 
18 // The above copyright notice and this permission notice shall be
19 // included in all copies or substantial portions of the Software.
20 // 
21 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
24 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
25 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
26 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
27 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28 //
29
30 using System;
31 using System.Runtime.InteropServices;
32 using System.Runtime.Serialization;
33
34 namespace System.Globalization {
35         [Serializable]
36         [ComVisible (true)]
37         public class CultureNotFoundException : ArgumentException, ISerializable {
38                 string invalid_culture_name;
39                 int? invalid_culture_id;
40
41                 public CultureNotFoundException () : base ("Culture not found")
42                 {
43                 }
44
45                 public CultureNotFoundException (string message) : base (message)
46                 {
47                 }
48
49                 protected CultureNotFoundException (SerializationInfo info, StreamingContext context)
50                                 : base (info, context)
51                 {
52                         invalid_culture_name = (string) info.GetValue ("invalid_culture_name", typeof (string));
53                         invalid_culture_id = (int?) info.GetValue ("invalid_culture_id", typeof (int?));
54                 }
55
56                 public CultureNotFoundException (string message, Exception innerException)
57                                 : base (message, innerException)
58                 {
59                 }
60
61                 public CultureNotFoundException (string paramName, string message)
62                                 : base (message, paramName)
63                 {
64                 }
65
66                 public CultureNotFoundException (string message, int invalidCultureId, Exception innerException)
67                                 : base (message, innerException)
68                 {
69                         invalid_culture_id = invalidCultureId;
70                 }
71
72                 public CultureNotFoundException (string paramName, int invalidCultureId, string message)
73                                 : base (message, paramName)
74                 {
75                         invalid_culture_id = invalidCultureId;
76                 }
77
78                 public CultureNotFoundException (string message, string invalidCultureName, Exception innerException)
79                                 : base (message, innerException)
80                 {
81                         invalid_culture_name = invalidCultureName;
82                 }
83
84                 public CultureNotFoundException (string paramName, string invalidCultureName, string message)
85                                 : base (message, paramName)
86                 {
87                         invalid_culture_name = invalidCultureName;
88                 }
89
90                 public override void GetObjectData(SerializationInfo info, StreamingContext context)
91                 {
92                         if (info == null)
93                                 throw new ArgumentNullException ("info");
94
95                         base.GetObjectData (info, context);
96                         info.AddValue ("invalid_culture_name", invalid_culture_name, typeof (string));
97                         info.AddValue ("invalid_culture_id", invalid_culture_id, typeof (int?));
98                 }
99
100                 public virtual int? InvalidCultureId {
101                         get { return invalid_culture_id; }
102                 }
103
104                 public virtual string InvalidCultureName {
105                         get { return invalid_culture_name; }
106                 }
107
108                 public override string Message {
109                         get {
110                                 if (invalid_culture_name == null && invalid_culture_id.HasValue == false)
111                                         return base.Message;
112
113                                 if (invalid_culture_name != null)
114                                         return String.Format ("Culture name {0} is invalid", invalid_culture_name);
115                                 return String.Format ("Culture ID {0} is invalid", invalid_culture_id);
116                         }
117                 }
118         }
119 }
120