mscorlib(4.0.0.0) API with additions
CultureNotFoundException.cs
3 using System.Security;
4 
5 namespace System.Globalization
6 {
9  [ComVisible(true)]
10  [__DynamicallyInvokable]
12  {
13  private string m_invalidCultureName;
14 
15  private int? m_invalidCultureId;
16 
19  public virtual int? InvalidCultureId => m_invalidCultureId;
20 
23  [__DynamicallyInvokable]
24  public virtual string InvalidCultureName
25  {
26  [__DynamicallyInvokable]
27  get
28  {
29  return m_invalidCultureName;
30  }
31  }
32 
33  private static string DefaultMessage => Environment.GetResourceString("Argument_CultureNotSupported");
34 
35  private string FormatedInvalidCultureId
36  {
37  get
38  {
39  if (InvalidCultureId.HasValue)
40  {
41  return string.Format(CultureInfo.InvariantCulture, "{0} (0x{0:x4})", InvalidCultureId.Value);
42  }
43  return InvalidCultureName;
44  }
45  }
46 
49  [__DynamicallyInvokable]
50  public override string Message
51  {
52  [__DynamicallyInvokable]
53  get
54  {
55  string message = base.Message;
56  if (m_invalidCultureId.HasValue || m_invalidCultureName != null)
57  {
58  string resourceString = Environment.GetResourceString("Argument_CultureInvalidIdentifier", FormatedInvalidCultureId);
59  if (message == null)
60  {
61  return resourceString;
62  }
63  return message + Environment.NewLine + resourceString;
64  }
65  return message;
66  }
67  }
68 
70  [__DynamicallyInvokable]
72  : base(DefaultMessage)
73  {
74  }
75 
78  [__DynamicallyInvokable]
79  public CultureNotFoundException(string message)
80  : base(message)
81  {
82  }
83 
87  [__DynamicallyInvokable]
88  public CultureNotFoundException(string paramName, string message)
89  : base(message, paramName)
90  {
91  }
92 
96  [__DynamicallyInvokable]
97  public CultureNotFoundException(string message, Exception innerException)
98  : base(message, innerException)
99  {
100  }
101 
106  public CultureNotFoundException(string paramName, int invalidCultureId, string message)
107  : base(message, paramName)
108  {
109  m_invalidCultureId = invalidCultureId;
110  }
111 
116  public CultureNotFoundException(string message, int invalidCultureId, Exception innerException)
117  : base(message, innerException)
118  {
119  m_invalidCultureId = invalidCultureId;
120  }
121 
126  [__DynamicallyInvokable]
127  public CultureNotFoundException(string paramName, string invalidCultureName, string message)
128  : base(message, paramName)
129  {
130  m_invalidCultureName = invalidCultureName;
131  }
132 
137  [__DynamicallyInvokable]
138  public CultureNotFoundException(string message, string invalidCultureName, Exception innerException)
139  : base(message, innerException)
140  {
141  m_invalidCultureName = invalidCultureName;
142  }
143 
148  : base(info, context)
149  {
150  m_invalidCultureId = (int?)info.GetValue("InvalidCultureId", typeof(int?));
151  m_invalidCultureName = (string)info.GetValue("InvalidCultureName", typeof(string));
152  }
153 
159  [SecurityCritical]
160  public override void GetObjectData(SerializationInfo info, StreamingContext context)
161  {
162  if (info == null)
163  {
164  throw new ArgumentNullException("info");
165  }
166  base.GetObjectData(info, context);
167  int? num = null;
168  num = m_invalidCultureId;
169  info.AddValue("InvalidCultureId", num, typeof(int?));
170  info.AddValue("InvalidCultureName", m_invalidCultureName, typeof(string));
171  }
172  }
173 }
static CultureInfo InvariantCulture
Gets the T:System.Globalization.CultureInfo object that is culture-independent (invariant).
Definition: CultureInfo.cs:263
static string NewLine
Gets the newline string defined for this environment.
Definition: Environment.cs:449
The exception that is thrown when a null reference (Nothing in Visual Basic) is passed to a method th...
Definition: __Canon.cs:3
CultureNotFoundException()
Initializes a new instance of the T:System.Globalization.CultureNotFoundException class with its mess...
Describes the source and destination of a given serialized stream, and provides an additional caller-...
CultureNotFoundException(string paramName, string invalidCultureName, string message)
Initializes a new instance of the T:System.Globalization.CultureNotFoundException class with a specif...
Provides information about, and means to manipulate, the current environment and platform....
Definition: Environment.cs:21
CultureNotFoundException(string paramName, string message)
Initializes a new instance of the T:System.Globalization.CultureNotFoundException class with a specif...
override void GetObjectData(SerializationInfo info, StreamingContext context)
Sets the T:System.Runtime.Serialization.SerializationInfo object with the parameter name and addition...
CultureNotFoundException(string message, int invalidCultureId, Exception innerException)
Initializes a new instance of the T:System.Globalization.CultureNotFoundException class with a specif...
Stores all the data needed to serialize or deserialize an object. This class cannot be inherited.
The exception that is thrown when one of the arguments provided to a method is not valid.
override string Message
Gets the error message that explains the reason for the exception.
Allows an object to control its own serialization and deserialization.
Definition: ISerializable.cs:8
CultureNotFoundException(string message, string invalidCultureName, Exception innerException)
Initializes a new instance of the T:System.Globalization.CultureNotFoundException class with a specif...
Represents errors that occur during application execution.To browse the .NET Framework source code fo...
Definition: Exception.cs:22
Specifies that the class can be serialized.
CultureNotFoundException(string message)
Initializes a new instance of the T:System.Globalization.CultureNotFoundException class with the spec...
virtual ? int InvalidCultureId
Gets the culture identifier that cannot be found.
CultureNotFoundException(string paramName, int invalidCultureId, string message)
Initializes a new instance of the T:System.Globalization.CultureNotFoundException class with a specif...
Provides information about a specific culture (called a locale for unmanaged code development)....
Definition: CultureInfo.cs:16
CultureNotFoundException(string message, Exception innerException)
Initializes a new instance of the T:System.Globalization.CultureNotFoundException class with a specif...
virtual string InvalidCultureName
Gets the culture name that cannot be found.
CultureNotFoundException(SerializationInfo info, StreamingContext context)
Initializes a new instance of the T:System.Globalization.CultureNotFoundException class using the spe...
The exception that is thrown when a method attempts to construct a culture that is not available.