2014-06-01 04:11:04 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Globalization;
|
2014-08-17 05:38:13 +00:00
|
|
|
|
using System.Text.RegularExpressions;
|
2014-06-01 04:11:04 +00:00
|
|
|
|
|
|
|
|
|
namespace MediaBrowser.Model.Extensions
|
|
|
|
|
{
|
2014-06-01 19:41:35 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Isolating these helpers allow this entire project to be easily converted to Java
|
|
|
|
|
/// </summary>
|
2014-06-01 04:11:04 +00:00
|
|
|
|
public static class StringHelper
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Equalses the ignore case.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="str1">The STR1.</param>
|
|
|
|
|
/// <param name="str2">The STR2.</param>
|
|
|
|
|
/// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
|
|
|
|
|
public static bool EqualsIgnoreCase(string str1, string str2)
|
|
|
|
|
{
|
|
|
|
|
return string.Equals(str1, str2, StringComparison.OrdinalIgnoreCase);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Indexes the of ignore case.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="str">The string.</param>
|
|
|
|
|
/// <param name="value">The value.</param>
|
|
|
|
|
/// <returns>System.Int32.</returns>
|
|
|
|
|
public static int IndexOfIgnoreCase(string str, string value)
|
|
|
|
|
{
|
|
|
|
|
return str.IndexOf(value, StringComparison.OrdinalIgnoreCase);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// To the string culture invariant.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="val">The value.</param>
|
|
|
|
|
/// <returns>System.String.</returns>
|
|
|
|
|
public static string ToStringCultureInvariant(int val)
|
|
|
|
|
{
|
|
|
|
|
return val.ToString(CultureInfo.InvariantCulture);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// To the string culture invariant.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="val">The value.</param>
|
|
|
|
|
/// <returns>System.String.</returns>
|
|
|
|
|
public static string ToStringCultureInvariant(long val)
|
|
|
|
|
{
|
|
|
|
|
return val.ToString(CultureInfo.InvariantCulture);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// To the string culture invariant.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="val">The value.</param>
|
|
|
|
|
/// <returns>System.String.</returns>
|
|
|
|
|
public static string ToStringCultureInvariant(double val)
|
|
|
|
|
{
|
|
|
|
|
return val.ToString(CultureInfo.InvariantCulture);
|
|
|
|
|
}
|
2014-07-01 04:06:28 +00:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Trims the start.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="str">The string.</param>
|
|
|
|
|
/// <param name="c">The c.</param>
|
|
|
|
|
/// <returns>System.String.</returns>
|
|
|
|
|
public static string TrimStart(string str, char c)
|
|
|
|
|
{
|
|
|
|
|
return str.TrimStart(c);
|
|
|
|
|
}
|
2014-08-17 05:38:13 +00:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Splits the specified string.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="str">The string.</param>
|
|
|
|
|
/// <param name="term">The term.</param>
|
|
|
|
|
/// <returns>System.String[].</returns>
|
|
|
|
|
public static string[] RegexSplit(string str, string term)
|
|
|
|
|
{
|
|
|
|
|
return Regex.Split(str, term, RegexOptions.IgnoreCase);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Splits the specified string.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="str">The string.</param>
|
|
|
|
|
/// <param name="term">The term.</param>
|
|
|
|
|
/// <param name="limit">The limit.</param>
|
|
|
|
|
/// <returns>System.String[].</returns>
|
|
|
|
|
public static string[] RegexSplit(string str, string term, int limit)
|
|
|
|
|
{
|
|
|
|
|
return new Regex(term).Split(str, limit);
|
|
|
|
|
}
|
2014-06-01 04:11:04 +00:00
|
|
|
|
}
|
|
|
|
|
}
|