mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
Remove DatHeaderField enum
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace SabreTools.Core.Tools
|
||||
{
|
||||
@@ -9,36 +8,6 @@ namespace SabreTools.Core.Tools
|
||||
{
|
||||
#region String to Enum
|
||||
|
||||
/// <summary>
|
||||
/// Get DatHeaderField value from input string
|
||||
/// </summary>
|
||||
/// <param name="DatHeaderField">String to get value from</param>
|
||||
/// <returns>DatHeaderField value corresponding to the string</returns>
|
||||
public static DatHeaderField AsDatHeaderField(this string? input)
|
||||
{
|
||||
// If the input is empty, we return null
|
||||
if (string.IsNullOrEmpty(input))
|
||||
return DatHeaderField.NULL;
|
||||
|
||||
// Normalize the input
|
||||
input = input!.ToLowerInvariant();
|
||||
|
||||
// Create regex
|
||||
string headerRegex = @"^(dat|header|datheader)[.\-_\s]";
|
||||
|
||||
// If we don't have a header field, skip
|
||||
if (!Regex.IsMatch(input, headerRegex))
|
||||
return DatHeaderField.NULL;
|
||||
|
||||
// Replace the match and re-normalize
|
||||
string headerInput = Regex.Replace(input, headerRegex, string.Empty)
|
||||
.Replace(' ', '_')
|
||||
.Replace('-', '_')
|
||||
.Replace('.', '_');
|
||||
|
||||
return AsEnumValue<DatHeaderField>(headerInput);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get bool? value from input string
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user