mirror of
https://github.com/lidarr/lidarr.git
synced 2025-07-12 08:07:10 -07:00
added better db migration support than what Subsonic provides out of the box.
This commit is contained in:
parent
180da4c82a
commit
ce63f05512
91 changed files with 7218 additions and 48 deletions
43
Migrator.net/Migrator.Framework/StringUtils.cs
Normal file
43
Migrator.net/Migrator.Framework/StringUtils.cs
Normal file
|
@ -0,0 +1,43 @@
|
|||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace Migrator.Framework
|
||||
{
|
||||
public class StringUtils
|
||||
{
|
||||
/// <summary>
|
||||
/// Convert a classname to something more readable.
|
||||
/// ex.: CreateATable => Create a table
|
||||
/// </summary>
|
||||
/// <param name="className"></param>
|
||||
/// <returns></returns>
|
||||
public static string ToHumanName(string className)
|
||||
{
|
||||
string name = Regex.Replace(className, "([A-Z])", " $1").Substring(1);
|
||||
return name.Substring(0, 1).ToUpper() + name.Substring(1).ToLower();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="template"></param>
|
||||
/// <param name="placeholder"></param>
|
||||
/// <param name="replacement"></param>
|
||||
/// <returns></returns>
|
||||
public static string ReplaceOnce(string template, string placeholder, string replacement)
|
||||
{
|
||||
int loc = template.IndexOf(placeholder);
|
||||
if (loc < 0)
|
||||
{
|
||||
return template;
|
||||
}
|
||||
else
|
||||
{
|
||||
return new StringBuilder(template.Substring(0, loc))
|
||||
.Append(replacement)
|
||||
.Append(template.Substring(loc + placeholder.Length))
|
||||
.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue