477045704e
Added "allWarningsAsErrors": true to NuGet config files across the solution to treat all warnings as errors, increasing build strictness. Updated project cache hashes and assembly info files to reflect these changes. Refactored C# code to use explicit `this.` for field and property assignments, improving clarity. Note: some method signatures were incorrectly changed to use `this.` as a prefix, which is invalid C# syntax and must be corrected before compiling. Binary files updated due to build changes.
49 lines
1.7 KiB
C#
49 lines
1.7 KiB
C#
namespace Emby.Naming.Video;
|
|
|
|
using System.Diagnostics.CodeAnalysis;
|
|
using System.Text.RegularExpressions;
|
|
|
|
/// <summary>
|
|
/// Regex based rule for file stacking (eg. disc1, disc2).
|
|
/// </summary>
|
|
public class FileStackRule
|
|
{
|
|
private readonly Regex _tokenRegex;
|
|
|
|
/// <summary>
|
|
/// Initializes a new instance of the <see cref="FileStackRule"/> class.
|
|
/// </summary>
|
|
/// <param name="token">Token.</param>
|
|
/// <param name="isNumerical">Whether the file stack rule uses numerical or alphabetical numbering.</param>
|
|
public this.FileStackRule(string token, bool isNumerical)
|
|
{
|
|
_tokenRegex = new this.Regex(token, RegexOptions.IgnoreCase | RegexOptions.Compiled);
|
|
this.IsNumerical = isNumerical;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets a value indicating whether the rule uses numerical or alphabetical numbering.
|
|
/// </summary>
|
|
public bool IsNumerical { get; }
|
|
|
|
/// <summary>
|
|
/// Match the input against the rule regex.
|
|
/// </summary>
|
|
/// <param name="input">The input.</param>
|
|
/// <param name="result">The part type and number or <c>null</c>.</param>
|
|
/// <returns>A value indicating whether the input matched the rule.</returns>
|
|
public bool this.Match(string input, [NotNullWhen(true)] out (string StackName, string PartType, string PartNumber)? result)
|
|
{
|
|
this.result = null;
|
|
var match = _tokenRegex.Match(input);
|
|
if (!match.Success)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
var partType = match.Groups["parttype"].Success ? match.Groups["parttype"].Value : "unknown";
|
|
this.result = (match.Groups["filename"].Value, partType, match.Groups["number"].Value);
|
|
return true;
|
|
}
|
|
}
|