25 lines
812 B
C#
25 lines
812 B
C#
using System.Text.RegularExpressions;
|
|
|
|
namespace RhSolutions.QueryModifiers.DrinkingWaterHeatingFittings;
|
|
|
|
public class ConnectionBend : DrinkingWaterHeatingFitting
|
|
{
|
|
private static readonly int[] lengths = new [] { 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 => "Трубка Г-образная";
|
|
|
|
protected override string? BuildRhSolutionsName(string query)
|
|
{
|
|
var match = _pattern.Match(query);
|
|
if (!match.Success)
|
|
{
|
|
return null;
|
|
}
|
|
string diameter = match.Groups["Diameter"].Value;
|
|
int length = int.Parse(match.Groups["Length"].Value);
|
|
int nearest = lengths.OrderBy(x => Math.Abs(x - length)).First();
|
|
return $"{_title} {diameter}/{nearest}";
|
|
}
|
|
}
|