2 // System.Globalization.CultureNotFoundException.cs
5 // Gonzalo Paniagua Javier (gonzalo@novell.com)
7 // Copyright (c) 2010 Novell (http://www.novell.com)
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:
18 // The above copyright notice and this permission notice shall be
19 // included in all copies or substantial portions of the Software.
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.
31 using System.Runtime.InteropServices;
32 using System.Runtime.Serialization;
34 namespace System.Globalization {
37 public class CultureNotFoundException : ArgumentException, ISerializable {
38 string invalid_culture_name;
39 int? invalid_culture_id;
41 public CultureNotFoundException () : base ("Culture not found")
45 public CultureNotFoundException (string message) : base (message)
49 protected CultureNotFoundException (SerializationInfo info, StreamingContext context)
50 : base (info, context)
52 invalid_culture_name = (string) info.GetValue ("invalid_culture_name", typeof (string));
53 invalid_culture_id = (int?) info.GetValue ("invalid_culture_id", typeof (int?));
56 public CultureNotFoundException (string message, Exception innerException)
57 : base (message, innerException)
61 public CultureNotFoundException (string paramName, string message)
62 : base (message, paramName)
66 public CultureNotFoundException (string message, int invalidCultureId, Exception innerException)
67 : base (message, innerException)
69 invalid_culture_id = invalidCultureId;
72 public CultureNotFoundException (string paramName, int invalidCultureId, string message)
73 : base (message, paramName)
75 invalid_culture_id = invalidCultureId;
78 public CultureNotFoundException (string message, string invalidCultureName, Exception innerException)
79 : base (message, innerException)
81 invalid_culture_name = invalidCultureName;
84 public CultureNotFoundException (string paramName, string invalidCultureName, string message)
85 : base (message, paramName)
87 invalid_culture_name = invalidCultureName;
90 public override void GetObjectData(SerializationInfo info, StreamingContext context)
93 throw new ArgumentNullException ("info");
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?));
100 public virtual int? InvalidCultureId {
101 get { return invalid_culture_id; }
104 public virtual string InvalidCultureName {
105 get { return invalid_culture_name; }
108 public override string Message {
110 if (invalid_culture_name == null && invalid_culture_id.HasValue == false)
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);