Add default adapter threads
This commit is contained in:
parent
6611bf2e26
commit
11e0fd8dfd
@ -34,6 +34,7 @@ public class RautitanFittingsTests : ProductParsersTests
|
||||
=> Invoke(productType: "Муфта соединительная", query, modified);
|
||||
|
||||
[TestCase("Переходник с внутренней резьбой 16xG 3/4\" для труб из сшитого полиэтилена аксиальный", "Переходник с внутренней резьбой -угольник-переходник 16 3/4")]
|
||||
[TestCase("Переходник на внутреннюю резьбу 20", "Переходник с внутренней резьбой -угольник-переходник 20 1/2")]
|
||||
public void AdapterInternalTest(string query, string modified)
|
||||
=> Invoke(productType: "Переходник на внутреннюю резьбу", query, modified);
|
||||
|
||||
|
@ -4,6 +4,16 @@ 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;
|
||||
@ -13,11 +23,16 @@ public abstract class Adapter : DrinkingWaterHeatingFitting
|
||||
return false;
|
||||
}
|
||||
Match thread = _thread.Match(input);
|
||||
string threadValue;
|
||||
if (!thread.Success)
|
||||
{
|
||||
return false;
|
||||
threadValue = _defaultThreads[diameter.Groups["Diameter"].Value];
|
||||
}
|
||||
output = $"{_title} {diameter.Groups["Diameter"]} {thread.Groups["Thread"]}";
|
||||
else
|
||||
{
|
||||
threadValue = thread.Groups["Thread"].Value;
|
||||
}
|
||||
output = $"{_title} {diameter.Groups["Diameter"]} {threadValue}";
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user