summaryrefslogtreecommitdiff
path: root/RhSolutions.Parsers/DrinkingWaterHeatingFittings/ThreadTPieceInternal.cs
blob: c0d939fb89ebfe8584823d181b6a405c605eaf98 (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
33
34
35
36
37
38
39
40
41
42
using System.Text.RegularExpressions;

namespace RhSolutions.Parsers.Fittings;

[ParserKey("Тройник RAUTITAN резьбовой внутренний")]
public class ThreadTPieceInternal : DrinkingWaterHeatingFitting
{
	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)
		{
			if (diameters[0] < 25)
			{
				output = $"Тройник настенный с внутренней резьбой {diameters[0]}-Rp{thread}-{diameters[0]}";
			}
			else
			{
				output = $"Тройник с внутр. резьбой на боков. проходе {diameters[0]}-Rp {thread}-{diameters[0]}";
			}
		}
		else
		{
			if (diameters[0] < 25)
			{
				output = $"Тройник настенный с внутренней резьбой {diameters[0]}-Rp{thread}-{diameters[1]}";
			}
			else
			{
				output = $"Тройник с внутр. резьбой на боков. проходе {diameters[0]}-Rp {thread}-{diameters[1]}";
			}
		}
		return true;
	}
}