0
0
RhSolutions-Api/RhSolutions.MLModifiers/DrinkingWaterHeatingFittings/DrinkingWaterHeatingFitting.cs

31 lines
816 B
C#
Raw Normal View History

2023-10-11 22:35:19 +03:00
using System.Text.RegularExpressions;
2024-01-26 15:50:41 +03:00
namespace RhSolutions.MLModifiers.DrinkingWaterHeatingFittings;
2023-10-11 22:35:19 +03:00
2024-01-26 15:50:41 +03:00
public abstract class DrinkingWaterHeatingFitting : IProductMLModifier
2023-10-11 22:35:19 +03:00
{
protected static readonly Regex _diameter =
2023-10-13 15:04:27 +03:00
new(@"([\b\D]|^)?(?<Diameter>16|20|25|32|40|50|63)([\b\D]|$)");
2023-10-11 22:35:19 +03:00
protected static readonly Regex _angle =
2023-10-13 15:04:27 +03:00
new(@"([\b\D])(?<Angle>45|90)([\b\D]|$)");
2023-10-11 22:35:19 +03:00
protected static readonly Regex _thread =
2023-10-13 15:04:27 +03:00
new(@"([\b\D])(?<Thread>1\s+1/4|1\s+1/2|1/2|3/4|2|1)([\b\D]|$)");
2023-10-11 22:35:19 +03:00
protected virtual string _title { get; } = string.Empty;
2023-10-22 13:43:18 +03:00
public virtual bool TryQueryModify(string input, out string output)
2023-10-11 22:35:19 +03:00
{
2023-10-22 13:43:18 +03:00
var match = _diameter.Match(input);
2023-10-11 22:35:19 +03:00
if (match.Success)
{
2023-10-22 13:43:18 +03:00
output = $"{_title} {match.Groups["Diameter"]}";
return true;
}
else
{
output = string.Empty;
return false;
2023-10-11 22:35:19 +03:00
}
}
2023-10-14 14:24:46 +03:00
}