summaryrefslogtreecommitdiff
path: root/RhSolutions.Parsers/DrinkingWaterHeatingFittings/ThreadElbowDoubleWallInternal.cs
blob: f45bc1f3d32868bcba1c89adfae6b07646c2e401 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
using System.Text.RegularExpressions;

namespace RhSolutions.Parsers.Fittings;

[ParserKey("Проточный настенный угольник")]
public class ThreadElbowDoubleWallInternal : DrinkingWaterHeatingFitting
{
	protected override string _title => "Проточный настенный угольник";
	private Regex _type = new(@"([\b\Wу])(?<Type>длин)([\b\w\.\s])");

	public override bool TryParse(string input, out string output)
	{
		output = string.Empty;
		var diameterMatches = _diameter.Matches(input);
		if (diameterMatches.Count == 0)
		{
			return false;
		}
		var threadMatch = _thread.Match(input);
		if (!threadMatch.Success)
		{
			return false;
		}
		var typeMatch = _type.Match(input);
		string[] diameters = diameterMatches.Select(x => x.Groups["Diameter"].Value).ToArray();
		string thread = threadMatch.Groups["Thread"].Value;
		string type = typeMatch.Success ? "длинный" : "короткий";
		
		output = $"{_title} {diameters[0]}/{(diameters.Length > 1 ? diameters[1] : diameters[0])}-Rp {thread} {type}";
		return true;
	}
}