summaryrefslogtreecommitdiff
path: root/RhSolutions.Parsers/DrinkingWaterHeatingFittings/ThreadTPieceExternal.cs
blob: 0a758657b6d23c1d616829e632c5227a7ca1909e (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
using System.Text.RegularExpressions;

namespace RhSolutions.Parsers.Fittings;

[ParserKey("Тройник RAUTITAN резьбовой наружный")]
public class ThreadTPieceExternal : DrinkingWaterHeatingFitting
{
	protected override string _title => "Тройник с наружной резьбой";

	public override bool TryParse(string input, out string output)
	{
		output = string.Empty;
		MatchCollection diametersMatches = _diameter.Matches(input);
		if (diametersMatches.Count == 0)
		{
			return false;
		}
		string thread = _thread.Match(input).Groups["Thread"].Value;
		int[] diameters = diametersMatches.Select(match => int.Parse(match.Groups["Diameter"].Value)).ToArray();
		if (diameters.Length == 1)
		{
			output = $"{_title} {diameters[0]}-{diameters[0]}-R {thread}";
		}
		else
		{
			output = $"{_title} {diameters[0]}-{diameters[1]}-R {thread}";
		}
		return true;
	}
}