0
0
RhSolutions-Api/RhSolutions.Parsers/DrinkingWaterHeatingFittings/Coupling.cs

31 lines
834 B
C#
Raw Normal View History

2024-02-08 17:11:11 +03:00
namespace RhSolutions.Parsers.Fittings;
2023-10-13 15:04:27 +03:00
2024-02-08 17:11:11 +03:00
[ParserKey("Муфта соединительная")]
2023-10-13 15:04:27 +03:00
public class Coupling : DrinkingWaterHeatingFitting
{
protected override string _title => "Муфта соединительная";
2023-10-22 13:43:18 +03:00
2024-02-08 17:11:11 +03:00
public override bool TryParse(string input, out string output)
2023-10-13 15:04:27 +03:00
{
2023-10-22 13:43:18 +03:00
output = string.Empty;
var diametersMatches = _diameter.Matches(input);
if (diametersMatches.Count == 0)
2023-10-13 15:04:27 +03:00
{
2023-10-22 13:43:18 +03:00
return false;
2023-10-13 15:04:27 +03:00
}
var diameters = diametersMatches.Select(x => x.Groups["Diameter"].Value)
.Take(2)
.OrderByDescending(x => int.Parse(x))
.ToArray();
if (diameters.Length == 1 || diameters[0] == diameters[1])
2023-10-22 13:43:18 +03:00
{
output = $"{_title} равнопроходная {diameters[0]}";
}
else
{
output = $"{_title} переходная {diameters[0]}-{diameters[1]}";
}
return true;
2023-10-13 15:04:27 +03:00
}
}