diff options
author | Stephen Toub <stoub@microsoft.com> | 2016-10-09 00:59:01 -0400 |
---|---|---|
committer | Jan Kotas <jkotas@microsoft.com> | 2016-10-08 21:59:01 -0700 |
commit | 71b817da9063df15274264ea039a761198072a85 (patch) | |
tree | 04950d62e1c1a7622bd12b9604427cb7cf9275e9 /src/mscorlib | |
parent | f9b7d0674eece73ca32754201bb138dbd6bba1c5 (diff) | |
download | coreclr-71b817da9063df15274264ea039a761198072a85.tar.gz coreclr-71b817da9063df15274264ea039a761198072a85.tar.bz2 coreclr-71b817da9063df15274264ea039a761198072a85.zip |
Implement CultureNotFoundException id-based ctors (#7536)
Diffstat (limited to 'src/mscorlib')
-rw-r--r-- | src/mscorlib/corefx/System/Globalization/CultureNotFoundException.cs | 33 | ||||
-rw-r--r-- | src/mscorlib/corefx/System/Globalization/STUBS.cs | 7 |
2 files changed, 29 insertions, 11 deletions
diff --git a/src/mscorlib/corefx/System/Globalization/CultureNotFoundException.cs b/src/mscorlib/corefx/System/Globalization/CultureNotFoundException.cs index 740063e4d3..794c6f7105 100644 --- a/src/mscorlib/corefx/System/Globalization/CultureNotFoundException.cs +++ b/src/mscorlib/corefx/System/Globalization/CultureNotFoundException.cs @@ -13,6 +13,7 @@ namespace System.Globalization public partial class CultureNotFoundException : ArgumentException, ISerializable { private string _invalidCultureName; // unrecognized culture name + private int? _invalidCultureId; // unrecognized culture Lcid public CultureNotFoundException() : base(DefaultMessage) @@ -46,8 +47,22 @@ namespace System.Globalization _invalidCultureName = invalidCultureName; } - protected CultureNotFoundException(SerializationInfo info, StreamingContext context) : base(info, context) + public CultureNotFoundException(string message, int invalidCultureId, Exception innerException) + : base(message, innerException) + { + _invalidCultureId = invalidCultureId; + } + + public CultureNotFoundException(string paramName, int invalidCultureId, string message) + : base(message, paramName) + { + _invalidCultureId = invalidCultureId; + } + + protected CultureNotFoundException(SerializationInfo info, StreamingContext context) + : base(info, context) { + _invalidCultureId = (int?)info.GetValue("InvalidCultureId", typeof(int?)); _invalidCultureName = (string)info.GetValue("InvalidCultureName", typeof(string)); } @@ -60,9 +75,15 @@ namespace System.Globalization } base.GetObjectData(info, context); + info.AddValue("InvalidCultureId", _invalidCultureId, typeof(int?)); info.AddValue("InvalidCultureName", _invalidCultureName, typeof(string)); } + public virtual Nullable<int> InvalidCultureId + { + get { return _invalidCultureId; } + } + public virtual string InvalidCultureName { get { return _invalidCultureName; } @@ -80,7 +101,9 @@ namespace System.Globalization { get { - return InvalidCultureName; + return InvalidCultureId != null ? + String.Format(CultureInfo.InvariantCulture, "{0} (0x{0:x4})", (int)InvalidCultureId) : + InvalidCultureName; } } @@ -89,12 +112,14 @@ namespace System.Globalization get { String s = base.Message; - if ( - _invalidCultureName != null) + if (_invalidCultureId != null || _invalidCultureName != null) { String valueMessage = SR.Format(SR.Argument_CultureInvalidIdentifier, FormatedInvalidCultureId); if (s == null) + { return valueMessage; + } + return s + Environment.NewLine + valueMessage; } return s; diff --git a/src/mscorlib/corefx/System/Globalization/STUBS.cs b/src/mscorlib/corefx/System/Globalization/STUBS.cs index 73e319e3cd..bddd05eeab 100644 --- a/src/mscorlib/corefx/System/Globalization/STUBS.cs +++ b/src/mscorlib/corefx/System/Globalization/STUBS.cs @@ -12,13 +12,6 @@ namespace System.Globalization public static System.Globalization.CultureInfo[] GetCultures(System.Globalization.CultureTypes types) { throw new NotImplementedException(); } } - public partial class CultureNotFoundException : System.ArgumentException, System.Runtime.Serialization.ISerializable - { - public CultureNotFoundException(string message, int invalidCultureId, System.Exception innerException) { throw new NotImplementedException(); } - public CultureNotFoundException(string paramName, int invalidCultureId, string message) { throw new NotImplementedException(); } - public virtual System.Nullable<int> InvalidCultureId { get { throw new NotImplementedException(); } } - } - public enum CultureTypes { AllCultures = 7, |