28 lines
902 B
C#
28 lines
902 B
C#
using System.Text.RegularExpressions;
|
|
|
|
namespace RhSolutions.MLModifiers.DrinkingWaterHeatingFittings;
|
|
|
|
[MLModifierKey("Трубка Г-образная")]
|
|
public class ConnectionBend : DrinkingWaterHeatingFitting
|
|
{
|
|
private static readonly int[] lengths = [250, 500, 1000];
|
|
private static readonly Regex _pattern =
|
|
new(@"([\b\D]|^)?(?<Diameter>16|20|25)(\D+|.*15.*)(?<Length>\b\d{3,4})([\b\D]|$)");
|
|
protected override string _title => "Трубка Г-образная";
|
|
|
|
public override bool TryQueryModify(string input, out string output)
|
|
{
|
|
output = string.Empty;
|
|
var match = _pattern.Match(input);
|
|
if (!match.Success)
|
|
{
|
|
return false;
|
|
}
|
|
string diameter = match.Groups["Diameter"].Value;
|
|
int length = int.Parse(match.Groups["Length"].Value);
|
|
int nearest = lengths.OrderBy(x => Math.Abs(x - length)).First();
|
|
output = $"{_title} {diameter}/{nearest}";
|
|
return true;
|
|
}
|
|
}
|