39 lines
835 B
C#
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;
|
|
}
|
|
}
|