mirror of
https://github.com/ICDSystems/ICD.Common.Utils.git
synced 2026-04-12 12:07:05 +00:00
feat: Clarifying neutral culture exception
This commit is contained in:
parent
6d08ee3bef
commit
c0ed7f9b26
1 changed files with 11 additions and 7 deletions
|
|
@ -201,7 +201,9 @@ namespace ICD.Common.Utils.Globalization
|
|||
{
|
||||
if (m_IsResident)
|
||||
return base.DateTimeFormat;
|
||||
CheckNeutral(this);
|
||||
|
||||
ThrowIfNeutralCulture(this);
|
||||
|
||||
if (m_DatetimeFormat == null)
|
||||
{
|
||||
DateTimeFormatInfo dateTimeFormatInfo = GetDateTimeFormat(m_DatetimeFormatId);
|
||||
|
|
@ -218,7 +220,7 @@ namespace ICD.Common.Utils.Globalization
|
|||
base.DateTimeFormat = value;
|
||||
return;
|
||||
}
|
||||
VerifyWritable();
|
||||
ThrowIfReadOnly();
|
||||
if (value == null)
|
||||
throw new ArgumentException("value");
|
||||
m_DatetimeFormat = value;
|
||||
|
|
@ -241,7 +243,9 @@ namespace ICD.Common.Utils.Globalization
|
|||
{
|
||||
if (m_IsResident)
|
||||
return base.NumberFormat;
|
||||
CheckNeutral(this);
|
||||
|
||||
ThrowIfNeutralCulture(this);
|
||||
|
||||
if (m_NumberFormat == null)
|
||||
{
|
||||
NumberFormatInfo numberFormatInfo = GetNumberFormat(m_NumberFormatId);
|
||||
|
|
@ -258,7 +262,7 @@ namespace ICD.Common.Utils.Globalization
|
|||
base.NumberFormat = value;
|
||||
return;
|
||||
}
|
||||
VerifyWritable();
|
||||
ThrowIfReadOnly();
|
||||
if (value == null)
|
||||
throw new ArgumentException("value");
|
||||
m_NumberFormat = value;
|
||||
|
|
@ -985,16 +989,16 @@ namespace ICD.Common.Utils.Globalization
|
|||
|
||||
#endregion
|
||||
|
||||
private void VerifyWritable()
|
||||
private void ThrowIfReadOnly()
|
||||
{
|
||||
if (IsReadOnly)
|
||||
throw new InvalidOperationException();
|
||||
}
|
||||
|
||||
private static void CheckNeutral(CultureInfo culture)
|
||||
private static void ThrowIfNeutralCulture(CultureInfo culture)
|
||||
{
|
||||
if (culture.IsNeutralCulture)
|
||||
throw new NotSupportedException();
|
||||
throw new NotSupportedException("A neutral culture does not provide enough information to display the correct numeric format");
|
||||
}
|
||||
|
||||
private static bool IsResident(string name)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue