0
0
RhSolutions-Api/RhSolutions.Parsers/DrinkingWaterHeatingFittings/Adapter.cs
Serghei Cebotari 11e0fd8dfd
All checks were successful
Test and release / test (push) Successful in 4m9s
Test and release / release-image (push) Successful in 4m23s
Add default adapter threads
2024-02-19 22:13:08 +03:00

39 lines
835 B
C#

using System.Text.RegularExpressions;
namespace RhSolutions.Parsers.Fittings;
public abstract class Adapter : DrinkingWaterHeatingFitting
{
protected Dictionary<string, string> _defaultThreads = new()
{
["16"] = "1/2",
["20"] = "1/2",
["25"] = "3/4",
["32"] = "1",
["40"] = "1 1/4",
["50"] = "1 1/2",
["63"] = "2"
};
public override bool TryParse(string input, out string output)
{
output = string.Empty;
Match diameter = _diameter.Match(input);
if (!diameter.Success)
{
return false;
}
Match thread = _thread.Match(input);
string threadValue;
if (!thread.Success)
{
threadValue = _defaultThreads[diameter.Groups["Diameter"].Value];
}
else
{
threadValue = thread.Groups["Thread"].Value;
}
output = $"{_title} {diameter.Groups["Diameter"]} {threadValue}";
return true;
}
}