2014-05-31 21:11:04 -07:00
|
|
|
|
using System.Globalization;
|
|
|
|
|
|
|
|
|
|
namespace MediaBrowser.Model.Extensions
|
|
|
|
|
{
|
2014-06-01 12:41:35 -07:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Isolating these helpers allow this entire project to be easily converted to Java
|
|
|
|
|
/// </summary>
|
2014-05-31 21:11:04 -07:00
|
|
|
|
public static class DoubleHelper
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Tries the parse culture invariant.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="s">The s.</param>
|
|
|
|
|
/// <param name="result">The result.</param>
|
|
|
|
|
/// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
|
|
|
|
|
public static bool TryParseCultureInvariant(string s, out double result)
|
|
|
|
|
{
|
|
|
|
|
return double.TryParse(s, NumberStyles.Any, CultureInfo.InvariantCulture, out result);
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-06-22 09:25:47 -07:00
|
|
|
|
|
2014-06-23 09:05:19 -07:00
|
|
|
|
public static class FloatHelper
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Tries the parse culture invariant.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="s">The s.</param>
|
|
|
|
|
/// <param name="result">The result.</param>
|
|
|
|
|
/// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
|
|
|
|
|
public static bool TryParseCultureInvariant(string s, out float result)
|
|
|
|
|
{
|
|
|
|
|
return float.TryParse(s, NumberStyles.Any, CultureInfo.InvariantCulture, out result);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-06-22 09:25:47 -07:00
|
|
|
|
public static class BoolHelper
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Tries the parse culture invariant.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="s">The s.</param>
|
|
|
|
|
/// <param name="result">The result.</param>
|
|
|
|
|
/// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
|
|
|
|
|
public static bool TryParseCultureInvariant(string s, out bool result)
|
|
|
|
|
{
|
|
|
|
|
return bool.TryParse(s, out result);
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-05-31 21:11:04 -07:00
|
|
|
|
}
|