Remove BuildRhSolutionsName methods
This commit is contained in:
parent
020922d749
commit
b91d8fbe99
@ -4,18 +4,20 @@ namespace RhSolutions.QueryModifiers.DrinkingWaterHeatingFittings;
|
||||
|
||||
public abstract class Adapter : DrinkingWaterHeatingFitting
|
||||
{
|
||||
protected override string? BuildRhSolutionsName(string query)
|
||||
public override bool TryQueryModify(string input, out string output)
|
||||
{
|
||||
Match diameter = _diameter.Match(query);
|
||||
output = string.Empty;
|
||||
Match diameter = _diameter.Match(input);
|
||||
if (!diameter.Success)
|
||||
{
|
||||
return null;
|
||||
return false;
|
||||
}
|
||||
Match thread = _thread.Match(query);
|
||||
Match thread = _thread.Match(input);
|
||||
if (!thread.Success)
|
||||
{
|
||||
return null;
|
||||
return false;
|
||||
}
|
||||
return $"{_title} {diameter.Groups["Diameter"]} {thread.Groups["Thread"]}";
|
||||
output = $"{_title} {diameter.Groups["Diameter"]} {thread.Groups["Thread"]}";
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -2,21 +2,23 @@
|
||||
|
||||
public class BendFormerHeating : DrinkingWaterHeatingFitting
|
||||
{
|
||||
protected override string _title => "Фиксатор поворота";
|
||||
protected override string? BuildRhSolutionsName(string query)
|
||||
{
|
||||
var diameterMatch = _diameter.Match(query);
|
||||
if (!diameterMatch.Success)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
string diameter = diameterMatch.Groups["Diameter"].Value;
|
||||
if (diameter == "16")
|
||||
{
|
||||
diameter += "/17";
|
||||
}
|
||||
var angleMatch = _angle.Match(query);
|
||||
string angle = angleMatch.Success ? angleMatch.Groups["Angle"].Value : "90";
|
||||
return $"{_title} {diameter}/{angle}°";
|
||||
}
|
||||
protected override string _title => "Фиксатор поворота";
|
||||
public override bool TryQueryModify(string input, out string output)
|
||||
{
|
||||
output = string.Empty;
|
||||
var diameterMatch = _diameter.Match(input);
|
||||
if (!diameterMatch.Success)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
string diameter = diameterMatch.Groups["Diameter"].Value;
|
||||
if (diameter == "16")
|
||||
{
|
||||
diameter += "/17";
|
||||
}
|
||||
var angleMatch = _angle.Match(input);
|
||||
string angle = angleMatch.Success ? angleMatch.Groups["Angle"].Value : "90";
|
||||
output = $"{_title} {diameter}/{angle}°";
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -2,17 +2,20 @@ namespace RhSolutions.QueryModifiers.DrinkingWaterHeatingFittings;
|
||||
|
||||
public class BendFormerSanitary : DrinkingWaterHeatingFitting
|
||||
{
|
||||
protected override string _title => "Фиксатор поворота с кольцами";
|
||||
protected override string? BuildRhSolutionsName(string query)
|
||||
{
|
||||
var diameterMatch = _diameter.Match(query);
|
||||
if (!diameterMatch.Success)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
string diameter = diameterMatch.Groups["Diameter"].Value;
|
||||
var angleMatch = _angle.Match(query);
|
||||
string angle = angleMatch.Success ? angleMatch.Groups["Angle"].Value : "90";
|
||||
return $"{_title} {angle}° {diameter}";
|
||||
}
|
||||
protected override string _title => "Фиксатор поворота с кольцами";
|
||||
|
||||
public override bool TryQueryModify(string input, out string output)
|
||||
{
|
||||
output = string.Empty;
|
||||
var diameterMatch = _diameter.Match(input);
|
||||
if (!diameterMatch.Success)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
string diameter = diameterMatch.Groups["Diameter"].Value;
|
||||
var angleMatch = _angle.Match(input);
|
||||
string angle = angleMatch.Success ? angleMatch.Groups["Angle"].Value : "90";
|
||||
output = $"{_title} {angle}° {diameter}";
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -9,16 +9,18 @@ public class ConnectionBend : DrinkingWaterHeatingFitting
|
||||
new(@"([\b\D]|^)?(?<Diameter>16|20|25)(\D+|.*15.*)(?<Length>\b\d{3,4})([\b\D]|$)");
|
||||
protected override string _title => "Трубка Г-образная";
|
||||
|
||||
protected override string? BuildRhSolutionsName(string query)
|
||||
public override bool TryQueryModify(string input, out string output)
|
||||
{
|
||||
var match = _pattern.Match(query);
|
||||
output = string.Empty;
|
||||
var match = _pattern.Match(input);
|
||||
if (!match.Success)
|
||||
{
|
||||
return null;
|
||||
return false;
|
||||
}
|
||||
string diameter = match.Groups["Diameter"].Value;
|
||||
int length = int.Parse(match.Groups["Length"].Value);
|
||||
int nearest = lengths.OrderBy(x => Math.Abs(x - length)).First();
|
||||
return $"{_title} {diameter}/{nearest}";
|
||||
output = $"{_title} {diameter}/{nearest}";
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -3,24 +3,27 @@ namespace RhSolutions.QueryModifiers.DrinkingWaterHeatingFittings;
|
||||
public class Coupling : DrinkingWaterHeatingFitting
|
||||
{
|
||||
protected override string _title => "Муфта соединительная";
|
||||
protected override string? BuildRhSolutionsName(string query)
|
||||
|
||||
public override bool TryQueryModify(string input, out string output)
|
||||
{
|
||||
var diametersMatches = _diameter.Matches(query);
|
||||
output = string.Empty;
|
||||
var diametersMatches = _diameter.Matches(input);
|
||||
if (diametersMatches.Count == 0)
|
||||
{
|
||||
return null;
|
||||
return false;
|
||||
}
|
||||
var diameters = diametersMatches.Select(x => x.Groups["Diameter"].Value)
|
||||
.Take(2)
|
||||
.OrderByDescending(x => int.Parse(x))
|
||||
.ToArray();
|
||||
if (diameters.Length == 1 || diameters[0] == diameters[1])
|
||||
{
|
||||
return $"{_title} равнопроходная {diameters[0]}";
|
||||
}
|
||||
else
|
||||
{
|
||||
return $"{_title} переходная {diameters[0]}-{diameters[1]}";
|
||||
}
|
||||
{
|
||||
output = $"{_title} равнопроходная {diameters[0]}";
|
||||
}
|
||||
else
|
||||
{
|
||||
output = $"{_title} переходная {diameters[0]}-{diameters[1]}";
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -13,19 +13,18 @@ public abstract class DrinkingWaterHeatingFitting : IProductQueryModifier
|
||||
|
||||
protected virtual string _title { get; } = string.Empty;
|
||||
|
||||
public bool TryQueryModify(string input, out string output)
|
||||
public virtual bool TryQueryModify(string input, out string output)
|
||||
{
|
||||
output = BuildRhSolutionsName(input) ?? string.Empty;
|
||||
return !string.IsNullOrEmpty(output);
|
||||
}
|
||||
|
||||
protected virtual string? BuildRhSolutionsName(string query)
|
||||
{
|
||||
var match = _diameter.Match(query);
|
||||
var match = _diameter.Match(input);
|
||||
if (match.Success)
|
||||
{
|
||||
return $"{_title} {match.Groups["Diameter"]}";
|
||||
output = $"{_title} {match.Groups["Diameter"]}";
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
output = string.Empty;
|
||||
return false;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -2,17 +2,20 @@ namespace RhSolutions.QueryModifiers.DrinkingWaterHeatingFittings;
|
||||
|
||||
public class ElbowModifier : DrinkingWaterHeatingFitting
|
||||
{
|
||||
protected override string _title { get; } = "Угольник RAUTITAN -PLATINUM";
|
||||
protected override string? BuildRhSolutionsName(string query)
|
||||
{
|
||||
var diameterMatch = _diameter.Match(query);
|
||||
if (!diameterMatch.Success)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
string diameter = diameterMatch.Groups["Diameter"].Value;
|
||||
var angleMatch = _angle.Match(query);
|
||||
string angle = angleMatch.Success ? angleMatch.Groups["Angle"].Value : "90";
|
||||
return $"{_title} {angle} {diameter}";
|
||||
}
|
||||
protected override string _title { get; } = "Угольник RAUTITAN -PLATINUM";
|
||||
|
||||
public override bool TryQueryModify(string input, out string output)
|
||||
{
|
||||
output = string.Empty;
|
||||
var diameterMatch = _diameter.Match(input);
|
||||
if (!diameterMatch.Success)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
string diameter = diameterMatch.Groups["Diameter"].Value;
|
||||
var angleMatch = _angle.Match(input);
|
||||
string angle = angleMatch.Success ? angleMatch.Groups["Angle"].Value : "90";
|
||||
output = $"{_title} {angle} {diameter}";
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -4,18 +4,19 @@ public abstract class Eurocone : DrinkingWaterHeatingFitting
|
||||
{
|
||||
protected virtual Dictionary<string, string> _titles { get; } = new();
|
||||
|
||||
protected override string? BuildRhSolutionsName(string query)
|
||||
public override bool TryQueryModify(string input, out string output)
|
||||
{
|
||||
var diameterMatch = _diameter.Match(query);
|
||||
output = string.Empty;
|
||||
var diameterMatch = _diameter.Match(input);
|
||||
if (diameterMatch.Success)
|
||||
{
|
||||
string diameter = diameterMatch.Groups["Diameter"].Value;
|
||||
if (_titles.TryGetValue(diameter, out string? title))
|
||||
{
|
||||
return title;
|
||||
output = title;
|
||||
return true;
|
||||
}
|
||||
else return null;
|
||||
}
|
||||
return null;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -3,14 +3,17 @@ namespace RhSolutions.QueryModifiers.DrinkingWaterHeatingFittings;
|
||||
public class EuroconeAdapter : DrinkingWaterHeatingFitting
|
||||
{
|
||||
protected override string _title => "Переходник на евроконус";
|
||||
protected override string? BuildRhSolutionsName(string query)
|
||||
|
||||
public override bool TryQueryModify(string input, out string output)
|
||||
{
|
||||
var diameterMatch = _diameter.Match(query);
|
||||
output = string.Empty;
|
||||
var diameterMatch = _diameter.Match(input);
|
||||
if (diameterMatch.Success)
|
||||
{
|
||||
string diameter = diameterMatch.Groups["Diameter"].Value;
|
||||
return $"{_title} {diameter}-G 3/4";
|
||||
output = $"{_title} {diameter}-G 3/4";
|
||||
return true;
|
||||
}
|
||||
return null;
|
||||
return false;
|
||||
}
|
||||
}
|
@ -2,8 +2,9 @@ namespace RhSolutions.QueryModifiers.DrinkingWaterHeatingFittings;
|
||||
|
||||
public class EuroconeConnectionBend : DrinkingWaterHeatingFitting
|
||||
{
|
||||
protected override string? BuildRhSolutionsName(string query)
|
||||
{
|
||||
return "Резьбозажимное соединение для металлической трубки G 3/4 -15";
|
||||
}
|
||||
public override bool TryQueryModify(string input, out string output)
|
||||
{
|
||||
output = "Резьбозажимное соединение для металлической трубки G 3/4 -15";
|
||||
return true;
|
||||
}
|
||||
}
|
@ -2,8 +2,9 @@ namespace RhSolutions.QueryModifiers.DrinkingWaterHeatingFittings;
|
||||
|
||||
public class Nippel : DrinkingWaterHeatingFitting
|
||||
{
|
||||
protected override string? BuildRhSolutionsName(string query)
|
||||
{
|
||||
return "К-т двух резьбозажим. нипелей с нар.резьбой 1/2х3/4";
|
||||
}
|
||||
public override bool TryQueryModify(string input, out string output)
|
||||
{
|
||||
output = "К-т двух резьбозажим. нипелей с нар.резьбой 1/2х3/4";
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -4,9 +4,10 @@ public class SupportingClip : DrinkingWaterHeatingFitting
|
||||
{
|
||||
protected override string _title => "Фиксирующий желоб для ПЭ-трубы";
|
||||
|
||||
protected override string? BuildRhSolutionsName(string query)
|
||||
public override bool TryQueryModify(string input, out string output)
|
||||
{
|
||||
var diameterMatch = _diameter.Match(query);
|
||||
output = string.Empty;
|
||||
var diameterMatch = _diameter.Match(input);
|
||||
if (diameterMatch.Success)
|
||||
{
|
||||
string diameter = diameterMatch.Groups["Diameter"].Value;
|
||||
@ -14,8 +15,9 @@ public class SupportingClip : DrinkingWaterHeatingFitting
|
||||
{
|
||||
diameter += "/17";
|
||||
}
|
||||
return $"{_title} {diameter}";
|
||||
output = $"{_title} {diameter}";
|
||||
return true;
|
||||
}
|
||||
return null;
|
||||
return false;
|
||||
}
|
||||
}
|
@ -2,24 +2,26 @@
|
||||
|
||||
public class TPiece : DrinkingWaterHeatingFitting
|
||||
{
|
||||
protected override string _title => "Тройник RAUTITAN -PLATINUM";
|
||||
protected override string _title => "Тройник RAUTITAN -PLATINUM";
|
||||
|
||||
protected override string? BuildRhSolutionsName(string query)
|
||||
{
|
||||
var diameters = _diameter.Matches(query)
|
||||
.Select(match => match.Groups["Diameter"].Value)
|
||||
.ToArray();
|
||||
if (diameters.Length == 1)
|
||||
{
|
||||
return $"{_title} {diameters[0]}-{diameters[0]}-{diameters[0]}";
|
||||
}
|
||||
else if (diameters.Length >= 3)
|
||||
{
|
||||
return $"{_title} {diameters[0]}-{diameters[1]}-{diameters[2]}";
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
public override bool TryQueryModify(string input, out string output)
|
||||
{
|
||||
output = string.Empty;
|
||||
var diameters = _diameter.Matches(input)
|
||||
.Select(match => match.Groups["Diameter"].Value)
|
||||
.ToArray();
|
||||
if (diameters.Length == 1)
|
||||
{
|
||||
output = $"{_title} {diameters[0]}-{diameters[0]}-{diameters[0]}";
|
||||
}
|
||||
else if (diameters.Length >= 3)
|
||||
{
|
||||
output = $"{_title} {diameters[0]}-{diameters[1]}-{diameters[2]}";
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -7,23 +7,25 @@ public class ThreadElbowDoubleWallInternal : DrinkingWaterHeatingFitting
|
||||
protected override string _title => "Проточный настенный угольник";
|
||||
private Regex _type = new(@"([\b\Wу])(?<Type>длин)([\b\w\.\s])");
|
||||
|
||||
protected override string? BuildRhSolutionsName(string query)
|
||||
public override bool TryQueryModify(string input, out string output)
|
||||
{
|
||||
var diameterMatches = _diameter.Matches(query);
|
||||
output = string.Empty;
|
||||
var diameterMatches = _diameter.Matches(input);
|
||||
if (diameterMatches.Count == 0)
|
||||
{
|
||||
return null;
|
||||
return false;
|
||||
}
|
||||
var threadMatch = _thread.Match(query);
|
||||
var threadMatch = _thread.Match(input);
|
||||
if (!threadMatch.Success)
|
||||
{
|
||||
return null;
|
||||
return false;
|
||||
}
|
||||
var typeMatch = _type.Match(query);
|
||||
var typeMatch = _type.Match(input);
|
||||
string[] diameters = diameterMatches.Select(x => x.Groups["Diameter"].Value).ToArray();
|
||||
string thread = threadMatch.Groups["Thread"].Value;
|
||||
string type = typeMatch.Success ? "длинный" : "короткий";
|
||||
|
||||
return $"{_title} {diameters[0]}/{(diameters.Length > 1 ? diameters[1] : diameters[0])}-Rp {thread} {type}";
|
||||
output = $"{_title} {diameters[0]}/{(diameters.Length > 1 ? diameters[1] : diameters[0])}-Rp {thread} {type}";
|
||||
return true;
|
||||
}
|
||||
}
|
@ -3,20 +3,23 @@ namespace RhSolutions.QueryModifiers.DrinkingWaterHeatingFittings;
|
||||
public class ThreadElbowWallExternal : DrinkingWaterHeatingFitting
|
||||
{
|
||||
protected override string _title => "Угольник настенный с наружной резьбой";
|
||||
protected override string? BuildRhSolutionsName(string query)
|
||||
|
||||
public override bool TryQueryModify(string input, out string output)
|
||||
{
|
||||
var diameterMatch = _diameter.Match(query);
|
||||
output = string.Empty;
|
||||
var diameterMatch = _diameter.Match(input);
|
||||
if (!diameterMatch.Success)
|
||||
{
|
||||
return null;
|
||||
return false;
|
||||
}
|
||||
var threadMatch = _thread.Match(query);
|
||||
var threadMatch = _thread.Match(input);
|
||||
if (!threadMatch.Success)
|
||||
{
|
||||
return null;
|
||||
return false;
|
||||
}
|
||||
string diameter = diameterMatch.Groups["Diameter"].Value;
|
||||
string thread = threadMatch.Groups["Thread"].Value;
|
||||
return $"{_title} {diameter}-R {thread}";
|
||||
output = $"{_title} {diameter}-R {thread}";
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -6,21 +6,24 @@ public class ThreadElbowWallInternal : DrinkingWaterHeatingFitting
|
||||
{
|
||||
protected override string _title => "Угольник настенный внутр. резьба";
|
||||
private Regex _type = new(@"([\b\Wу])(?<Type>длин)([\b\w\.\s])");
|
||||
protected override string? BuildRhSolutionsName(string query)
|
||||
|
||||
public override bool TryQueryModify(string input, out string output)
|
||||
{
|
||||
var diameterMatch = _diameter.Match(query);
|
||||
output = string.Empty;
|
||||
var diameterMatch = _diameter.Match(input);
|
||||
if (!diameterMatch.Success)
|
||||
{
|
||||
return null;
|
||||
return false;
|
||||
}
|
||||
var threadMatch = _thread.Match(query);
|
||||
var threadMatch = _thread.Match(input);
|
||||
if (!threadMatch.Success)
|
||||
{
|
||||
return null;
|
||||
return false;
|
||||
}
|
||||
var typeMatch = _type.Match(query);
|
||||
var typeMatch = _type.Match(input);
|
||||
string diameter = diameterMatch.Groups["Diameter"].Value;
|
||||
string thread = threadMatch.Groups["Thread"].Value;
|
||||
return $"{_title} {(typeMatch.Success ? "длинный " : string.Empty)}{diameter}-Rp {thread}";
|
||||
output = $"{_title} {(typeMatch.Success ? "длинный " : string.Empty)}{diameter}-Rp {thread}";
|
||||
return true;
|
||||
}
|
||||
}
|
@ -4,23 +4,26 @@ namespace RhSolutions.QueryModifiers.DrinkingWaterHeatingFittings;
|
||||
|
||||
public class ThreadTPieceExternal : DrinkingWaterHeatingFitting
|
||||
{
|
||||
protected override string _title => "Тройник RAUTITAN с наружной резьбой";
|
||||
protected override string? BuildRhSolutionsName(string query)
|
||||
{
|
||||
MatchCollection diametersMatches = _diameter.Matches(query);
|
||||
if (diametersMatches.Count == 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
string thread = _thread.Match(query).Groups["Thread"].Value;
|
||||
int[] diameters = diametersMatches.Select(match => int.Parse(match.Groups["Diameter"].Value)).ToArray();
|
||||
if (diameters.Length == 1)
|
||||
{
|
||||
return $"{_title} {diameters[0]}-{diameters[0]}-R {thread}";
|
||||
}
|
||||
else
|
||||
{
|
||||
return $"{_title} {diameters[0]}-{diameters[1]}-R {thread}";
|
||||
}
|
||||
}
|
||||
protected override string _title => "Тройник RAUTITAN с наружной резьбой";
|
||||
|
||||
public override bool TryQueryModify(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;
|
||||
}
|
||||
}
|
@ -4,36 +4,38 @@ namespace RhSolutions.QueryModifiers.DrinkingWaterHeatingFittings;
|
||||
|
||||
public class ThreadTPieceInternal : DrinkingWaterHeatingFitting
|
||||
{
|
||||
protected override string? BuildRhSolutionsName(string query)
|
||||
{
|
||||
MatchCollection diametersMatches = _diameter.Matches(query);
|
||||
if (diametersMatches.Count == 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
string thread = _thread.Match(query).Groups["Thread"].Value;
|
||||
int[] diameters = diametersMatches.Select(match => int.Parse(match.Groups["Diameter"].Value)).ToArray();
|
||||
if (diameters.Length == 1)
|
||||
{
|
||||
if (diameters[0] < 25)
|
||||
{
|
||||
return $"Тройник RAUTITAN настенный с внутренней резьбой {diameters[0]}-Rp{thread}-{diameters[0]}";
|
||||
}
|
||||
else
|
||||
{
|
||||
return $"Тройник RAUTITAN с внутр. резьбой на боков. проходе {diameters[0]}-Rp {thread}-{diameters[0]}";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (diameters[0] < 25)
|
||||
{
|
||||
return $"Тройник RAUTITAN настенный с внутренней резьбой {diameters[0]}-Rp{thread}-{diameters[1]}";
|
||||
}
|
||||
else
|
||||
{
|
||||
return $"Тройник RAUTITAN с внутр. резьбой на боков. проходе {diameters[0]}-Rp {thread}-{diameters[1]}";
|
||||
}
|
||||
}
|
||||
}
|
||||
public override bool TryQueryModify(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 = $"Тройник RAUTITAN настенный с внутренней резьбой {diameters[0]}-Rp{thread}-{diameters[0]}";
|
||||
}
|
||||
else
|
||||
{
|
||||
output = $"Тройник RAUTITAN с внутр. резьбой на боков. проходе {diameters[0]}-Rp {thread}-{diameters[0]}";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (diameters[0] < 25)
|
||||
{
|
||||
output = $"Тройник RAUTITAN настенный с внутренней резьбой {diameters[0]}-Rp{thread}-{diameters[1]}";
|
||||
}
|
||||
else
|
||||
{
|
||||
output = $"Тройник RAUTITAN с внутр. резьбой на боков. проходе {diameters[0]}-Rp {thread}-{diameters[1]}";
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -1,62 +1,56 @@
|
||||
using System.Text.RegularExpressions;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Http.Extensions;
|
||||
|
||||
namespace RhSolutions.QueryModifiers.DrinkingWaterHeatingPipes;
|
||||
|
||||
public class DrinkingWaterHeatingPipe : IProductQueryModifier
|
||||
{
|
||||
protected static readonly Regex _diameter =
|
||||
new(@"([\b\D]|^)?(?<Diameter>16|20|25|32|40|50|63)([\b\D]|$)");
|
||||
protected static readonly Regex _type =
|
||||
new(@"([\b\W])(?<Type>бухт|отр|штанг)([\b\w\.\s])");
|
||||
protected virtual string _title { get; } = string.Empty;
|
||||
protected static readonly Regex _diameter =
|
||||
new(@"([\b\D]|^)?(?<Diameter>16|20|25|32|40|50|63)([\b\D]|$)");
|
||||
protected static readonly Regex _type =
|
||||
new(@"([\b\W])(?<Type>бухт|отр|штанг)([\b\w\.\s])");
|
||||
protected virtual string _title { get; } = string.Empty;
|
||||
|
||||
protected virtual Dictionary<int, string> _diameterNames { get; } = new()
|
||||
{
|
||||
[16] = "16x2,2",
|
||||
[20] = "20x2,8",
|
||||
[25] = "25x3,5",
|
||||
[32] = "32x4,4",
|
||||
[40] = "40x5,5",
|
||||
[50] = "50x6,9",
|
||||
[63] = "63x8,6"
|
||||
};
|
||||
protected virtual Dictionary<int, string> _diameterNames { get; } = new()
|
||||
{
|
||||
[16] = "16x2,2",
|
||||
[20] = "20x2,8",
|
||||
[25] = "25x3,5",
|
||||
[32] = "32x4,4",
|
||||
[40] = "40x5,5",
|
||||
[50] = "50x6,9",
|
||||
[63] = "63x8,6"
|
||||
};
|
||||
|
||||
protected virtual Dictionary<string, string> _makeUp { get; } = new()
|
||||
{
|
||||
["бухт"] = "бухта",
|
||||
["штанг"] = "прям.отрезки",
|
||||
["отр"] = "прям.отрезки"
|
||||
};
|
||||
protected virtual Dictionary<string, string> _makeUp { get; } = new()
|
||||
{
|
||||
["бухт"] = "бухта",
|
||||
["штанг"] = "прям.отрезки",
|
||||
["отр"] = "прям.отрезки"
|
||||
};
|
||||
|
||||
public bool TryQueryModify(string input, out string output)
|
||||
{
|
||||
output = BuildRhSolutionsName(input) ?? string.Empty;
|
||||
return !string.IsNullOrEmpty(output);
|
||||
output = string.Empty;
|
||||
var diameterMatch = _diameter.Match(input);
|
||||
if (!diameterMatch.Success)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
var diameter = int.Parse(diameterMatch.Groups["Diameter"].Value);
|
||||
var typeMatch = _type.Match(input);
|
||||
if (typeMatch.Success)
|
||||
{
|
||||
var type = typeMatch.Groups["Type"].Value;
|
||||
output = $"Труба {_title} {_diameterNames[diameter]} {_makeUp[type]}";
|
||||
}
|
||||
else if (diameter < 32)
|
||||
{
|
||||
output = $"Труба {_title} {_diameterNames[diameter]} {_makeUp["бухт"]}";
|
||||
}
|
||||
else
|
||||
{
|
||||
output = $"Труба {_title} {_diameterNames[diameter]} {_makeUp["отр"]}";
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
protected virtual string? BuildRhSolutionsName(string query)
|
||||
{
|
||||
var diameterMatch = _diameter.Match(query);
|
||||
if (!diameterMatch.Success)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
var diameter = int.Parse(diameterMatch.Groups["Diameter"].Value);
|
||||
var typeMatch = _type.Match(query);
|
||||
if (typeMatch.Success)
|
||||
{
|
||||
var type = typeMatch.Groups["Type"].Value;
|
||||
return $"Труба {_title} {_diameterNames[diameter]} {_makeUp[type]}";
|
||||
}
|
||||
else if (diameter < 32)
|
||||
{
|
||||
return $"Труба {_title} {_diameterNames[diameter]} {_makeUp["бухт"]}";
|
||||
}
|
||||
else
|
||||
{
|
||||
return $"Труба {_title} {_diameterNames[diameter]} {_makeUp["отр"]}";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,4 @@
|
||||
using Microsoft.AspNetCore.Http;
|
||||
|
||||
namespace RhSolutions.QueryModifiers;
|
||||
namespace RhSolutions.QueryModifiers;
|
||||
|
||||
public interface IProductQueryModifier
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user