diff options
author | Serghei Cebotari <serghei@cebotari.ru> | 2024-02-08 17:11:11 +0300 |
---|---|---|
committer | Serghei Cebotari <serghei@cebotari.ru> | 2024-02-08 17:11:11 +0300 |
commit | 69db707d6803ada3891e4e71b8660ad095392973 (patch) | |
tree | d188676a0a5c40816fc6fa73955e883ea1f8c206 /RhSolutions.Parsers/DrinkingWaterHeatingPipes | |
parent | a9ce0c1785ce7c220ff953db7a21cf33535c6d26 (diff) |
Rename Parser projects
Diffstat (limited to 'RhSolutions.Parsers/DrinkingWaterHeatingPipes')
5 files changed, 121 insertions, 0 deletions
diff --git a/RhSolutions.Parsers/DrinkingWaterHeatingPipes/BlackPipe.cs b/RhSolutions.Parsers/DrinkingWaterHeatingPipes/BlackPipe.cs new file mode 100644 index 0000000..ca94117 --- /dev/null +++ b/RhSolutions.Parsers/DrinkingWaterHeatingPipes/BlackPipe.cs @@ -0,0 +1,17 @@ +namespace RhSolutions.Parsers.Pipes; + +[ParserKey("Black")] +public class BlackPipe : DrinkingWaterHeatingPipe +{ + protected override string _title => "Black"; + protected override Dictionary<int, string> _diameterNames => new() + { + [16] = "16х2,2", + [20] = "20х2,8", + [25] = "25х3,5", + [32] = string.Empty, + [40] = string.Empty, + [50] = string.Empty, + [63] = string.Empty + }; +} diff --git a/RhSolutions.Parsers/DrinkingWaterHeatingPipes/DrinkingWaterHeatingPipe.cs b/RhSolutions.Parsers/DrinkingWaterHeatingPipes/DrinkingWaterHeatingPipe.cs new file mode 100644 index 0000000..f3e0fc2 --- /dev/null +++ b/RhSolutions.Parsers/DrinkingWaterHeatingPipes/DrinkingWaterHeatingPipe.cs @@ -0,0 +1,56 @@ +using System.Text.RegularExpressions; + +namespace RhSolutions.Parsers.Pipes; + +public abstract class DrinkingWaterHeatingPipe : IProductParser +{ + 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<string, string> _makeUp { get; } = new() + { + ["бухт"] = "бухта", + ["штанг"] = "прям.отрезки", + ["отр"] = "прям.отрезки" + }; + + public bool TryParse(string input, out string 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; + } +} diff --git a/RhSolutions.Parsers/DrinkingWaterHeatingPipes/FlexPipe.cs b/RhSolutions.Parsers/DrinkingWaterHeatingPipes/FlexPipe.cs new file mode 100644 index 0000000..4a98634 --- /dev/null +++ b/RhSolutions.Parsers/DrinkingWaterHeatingPipes/FlexPipe.cs @@ -0,0 +1,7 @@ +namespace RhSolutions.Parsers.Pipes; + +[ParserKey("Flex")] +public class FlexPipe : DrinkingWaterHeatingPipe +{ + protected override string _title => "Flex"; +}
\ No newline at end of file diff --git a/RhSolutions.Parsers/DrinkingWaterHeatingPipes/PinkPipe.cs b/RhSolutions.Parsers/DrinkingWaterHeatingPipes/PinkPipe.cs new file mode 100644 index 0000000..d40483a --- /dev/null +++ b/RhSolutions.Parsers/DrinkingWaterHeatingPipes/PinkPipe.cs @@ -0,0 +1,24 @@ +namespace RhSolutions.Parsers.Pipes; + +[ParserKey("Pink")] +public class PinkPipe : DrinkingWaterHeatingPipe +{ + protected override string _title => "Pink+"; + + protected override Dictionary<string, string> _makeUp => new() + { + ["бухт"] = "бухта", + ["штанг"] = "прямые отрезки", + ["отр"] = "прямые отрезки" + }; + protected override Dictionary<int, string> _diameterNames => new() + { + [16] = "16х2,2", + [20] = "20х2,8", + [25] = "25х3,5", + [32] = "32х4,4", + [40] = "40х5,5", + [50] = "50х6,9", + [63] = "63х8,7" + }; +} diff --git a/RhSolutions.Parsers/DrinkingWaterHeatingPipes/StabilPipe.cs b/RhSolutions.Parsers/DrinkingWaterHeatingPipes/StabilPipe.cs new file mode 100644 index 0000000..1a52562 --- /dev/null +++ b/RhSolutions.Parsers/DrinkingWaterHeatingPipes/StabilPipe.cs @@ -0,0 +1,17 @@ +namespace RhSolutions.Parsers.Pipes; + +[ParserKey("Stabil")] +public class StabilPipe : DrinkingWaterHeatingPipe +{ + protected override string _title => "Stabil -PLATINUM"; + protected override Dictionary<int, string> _diameterNames => new() + { + [16] = "16,2х2,6", + [20] = "20х2,9", + [25] = "25х3,7", + [32] = "32х4,7", + [40] = "40х6,0", + [50] = "50x6,9", + [63] = "63x8,6" + }; +} |