mirror of
https://github.com/ICDSystems/ICD.Common.Utils.git
synced 2026-04-14 04:58:33 +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)
|
if (m_IsResident)
|
||||||
return base.DateTimeFormat;
|
return base.DateTimeFormat;
|
||||||
CheckNeutral(this);
|
|
||||||
|
ThrowIfNeutralCulture(this);
|
||||||
|
|
||||||
if (m_DatetimeFormat == null)
|
if (m_DatetimeFormat == null)
|
||||||
{
|
{
|
||||||
DateTimeFormatInfo dateTimeFormatInfo = GetDateTimeFormat(m_DatetimeFormatId);
|
DateTimeFormatInfo dateTimeFormatInfo = GetDateTimeFormat(m_DatetimeFormatId);
|
||||||
|
|
@ -218,7 +220,7 @@ namespace ICD.Common.Utils.Globalization
|
||||||
base.DateTimeFormat = value;
|
base.DateTimeFormat = value;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
VerifyWritable();
|
ThrowIfReadOnly();
|
||||||
if (value == null)
|
if (value == null)
|
||||||
throw new ArgumentException("value");
|
throw new ArgumentException("value");
|
||||||
m_DatetimeFormat = value;
|
m_DatetimeFormat = value;
|
||||||
|
|
@ -241,7 +243,9 @@ namespace ICD.Common.Utils.Globalization
|
||||||
{
|
{
|
||||||
if (m_IsResident)
|
if (m_IsResident)
|
||||||
return base.NumberFormat;
|
return base.NumberFormat;
|
||||||
CheckNeutral(this);
|
|
||||||
|
ThrowIfNeutralCulture(this);
|
||||||
|
|
||||||
if (m_NumberFormat == null)
|
if (m_NumberFormat == null)
|
||||||
{
|
{
|
||||||
NumberFormatInfo numberFormatInfo = GetNumberFormat(m_NumberFormatId);
|
NumberFormatInfo numberFormatInfo = GetNumberFormat(m_NumberFormatId);
|
||||||
|
|
@ -258,7 +262,7 @@ namespace ICD.Common.Utils.Globalization
|
||||||
base.NumberFormat = value;
|
base.NumberFormat = value;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
VerifyWritable();
|
ThrowIfReadOnly();
|
||||||
if (value == null)
|
if (value == null)
|
||||||
throw new ArgumentException("value");
|
throw new ArgumentException("value");
|
||||||
m_NumberFormat = value;
|
m_NumberFormat = value;
|
||||||
|
|
@ -985,16 +989,16 @@ namespace ICD.Common.Utils.Globalization
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
private void VerifyWritable()
|
private void ThrowIfReadOnly()
|
||||||
{
|
{
|
||||||
if (IsReadOnly)
|
if (IsReadOnly)
|
||||||
throw new InvalidOperationException();
|
throw new InvalidOperationException();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void CheckNeutral(CultureInfo culture)
|
private static void ThrowIfNeutralCulture(CultureInfo culture)
|
||||||
{
|
{
|
||||||
if (culture.IsNeutralCulture)
|
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)
|
private static bool IsResident(string name)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue