ec1f5dc317
Add Argument*Exceptions now use proper nameof operators. Added exception messages to quite a few Argument*Exceptions. Fixed rethorwing to be proper syntax. Added a ton of null checkes. (This is only a start, there are about 500 places that need proper null handling) Added some TODOs to log certain exceptions. Fix sln again. Fixed all AssemblyInfo's and added proper copyright (where I could find them) We live in *current year*. Fixed the use of braces. Fixed a ton of properties, and made a fair amount of functions static that should be and can be static. Made more Methods that should be static static. You can now use static to find bad functions! Removed unused variable. And added one more proper XML comment.
50 lines
1.2 KiB
C#
50 lines
1.2 KiB
C#
using System.Collections.Generic;
|
|
using System.Text.RegularExpressions;
|
|
|
|
namespace Emby.Naming.Video
|
|
{
|
|
/// <summary>
|
|
/// http://kodi.wiki/view/Advancedsettings.xml#video
|
|
/// </summary>
|
|
public class CleanStringParser
|
|
{
|
|
public CleanStringResult Clean(string name, IEnumerable<Regex> expressions)
|
|
{
|
|
var hasChanged = false;
|
|
|
|
foreach (var exp in expressions)
|
|
{
|
|
var result = Clean(name, exp);
|
|
|
|
if (!string.IsNullOrEmpty(result.Name))
|
|
{
|
|
name = result.Name;
|
|
hasChanged = hasChanged || result.HasChanged;
|
|
}
|
|
}
|
|
|
|
return new CleanStringResult
|
|
{
|
|
Name = name,
|
|
HasChanged = hasChanged
|
|
};
|
|
}
|
|
|
|
private static CleanStringResult Clean(string name, Regex expression)
|
|
{
|
|
var result = new CleanStringResult();
|
|
|
|
var match = expression.Match(name);
|
|
|
|
if (match.Success)
|
|
{
|
|
result.HasChanged = true;
|
|
name = name.Substring(0, match.Index);
|
|
}
|
|
|
|
result.Name = name;
|
|
return result;
|
|
}
|
|
}
|
|
}
|