From 73569a43644309d0342817580bcfd86c1face5b8 Mon Sep 17 00:00:00 2001 From: Sergey Chebotar Date: Tue, 20 Dec 2022 12:27:47 +0300 Subject: [PATCH] Namespace refactoring --- src/{AddIn => }/AddIn.cs | 3 +- .../CombineTool.cs | 6 +-- .../ConvertTool.cs | 4 +- .../ExportTool.cs | 4 +- .../MergeTool.cs | 4 +- .../RibbonController.cs | 16 +++--- .../ToolBase.cs | 8 +-- src/{Interface => Models}/Dialog.cs | 2 +- .../PriceListBase.cs | 2 +- .../PriceListHeaders.cs | 2 +- src/{PriceListTools => Models}/Product.cs | 2 +- src/{Interface => Models}/ProgressBar.cs | 4 +- src/{Interface => Models}/ResultBar.cs | 2 +- src/{AddIn => Models}/Sku.cs | 2 +- src/{AddIn => Models}/SkuExtensions.cs | 2 +- .../SourcePriceList.cs | 3 +- src/{Interface => Models}/StatusbarBase.cs | 6 +-- .../TargetPriceList.cs | 4 +- src/{AddIn => Models}/WorksheetExtensions.cs | 4 +- src/RhSolutions-AddIn.dna | 2 +- src/RhSolutions.csproj | 50 +++++++++---------- src/{AddIn => Services}/EventsUtil.cs | 9 ++-- src/{AddIn => Services}/Functions.cs | 2 +- src/{AddIn => Services}/RegistryUtil.cs | 9 ++-- src/{AddIn => Services}/RhDatabaseClient.cs | 4 +- 25 files changed, 79 insertions(+), 77 deletions(-) rename src/{AddIn => }/AddIn.cs (91%) rename src/{PriceListTools => Controllers}/CombineTool.cs (94%) rename src/{PriceListTools => Controllers}/ConvertTool.cs (91%) rename src/{PriceListTools => Controllers}/ExportTool.cs (97%) rename src/{PriceListTools => Controllers}/MergeTool.cs (94%) rename src/{Interface => Controllers}/RibbonController.cs (90%) rename src/{PriceListTools => Controllers}/ToolBase.cs (97%) rename src/{Interface => Models}/Dialog.cs (97%) rename src/{PriceListTools => Models}/PriceListBase.cs (91%) rename src/{PriceListTools => Models}/PriceListHeaders.cs (91%) rename src/{PriceListTools => Models}/Product.cs (95%) rename src/{Interface => Models}/ProgressBar.cs (83%) rename src/{Interface => Models}/ResultBar.cs (97%) rename src/{AddIn => Models}/Sku.cs (98%) rename src/{AddIn => Models}/SkuExtensions.cs (88%) rename src/{PriceListTools => Models}/SourcePriceList.cs (98%) rename src/{Interface => Models}/StatusbarBase.cs (74%) rename src/{PriceListTools => Models}/TargetPriceList.cs (88%) rename src/{AddIn => Models}/WorksheetExtensions.cs (94%) rename src/{AddIn => Services}/EventsUtil.cs (75%) rename src/{AddIn => Services}/Functions.cs (96%) rename src/{AddIn => Services}/RegistryUtil.cs (94%) rename src/{AddIn => Services}/RhDatabaseClient.cs (91%) diff --git a/src/AddIn/AddIn.cs b/src/AddIn.cs similarity index 91% rename from src/AddIn/AddIn.cs rename to src/AddIn.cs index b8bfd21..8c44821 100644 --- a/src/AddIn/AddIn.cs +++ b/src/AddIn.cs @@ -1,12 +1,13 @@ using ExcelDna.Integration; using ExcelDna.IntelliSense; using Microsoft.Office.Interop.Excel; +using RhSolutions.Services; using System.Net.Http; using System.Runtime.Caching; namespace RhSolutions { - class AddIn : IExcelAddIn + class RhSolutionsAddIn : IExcelAddIn { public static Application Excel; public static HttpClient httpClient; diff --git a/src/PriceListTools/CombineTool.cs b/src/Controllers/CombineTool.cs similarity index 94% rename from src/PriceListTools/CombineTool.cs rename to src/Controllers/CombineTool.cs index e0429bd..75c0f51 100644 --- a/src/PriceListTools/CombineTool.cs +++ b/src/Controllers/CombineTool.cs @@ -1,11 +1,11 @@ using Microsoft.Office.Interop.Excel; -using RhSolutions.Interface; +using RhSolutions.Models; using System; using System.Collections.Generic; using System.Linq; -using Dialog = RhSolutions.Interface.Dialog; +using Dialog = RhSolutions.Models.Dialog; -namespace RhSolutions.PriceListTools +namespace RhSolutions.Controllers { internal class CombineTool : ToolBase { diff --git a/src/PriceListTools/ConvertTool.cs b/src/Controllers/ConvertTool.cs similarity index 91% rename from src/PriceListTools/ConvertTool.cs rename to src/Controllers/ConvertTool.cs index 788d6ff..5b2cd4d 100644 --- a/src/PriceListTools/ConvertTool.cs +++ b/src/Controllers/ConvertTool.cs @@ -1,6 +1,6 @@ -using RhSolutions.Interface; +using RhSolutions.Models; -namespace RhSolutions.PriceListTools +namespace RhSolutions.Controllers { internal class ConvertTool : ToolBase { diff --git a/src/PriceListTools/ExportTool.cs b/src/Controllers/ExportTool.cs similarity index 97% rename from src/PriceListTools/ExportTool.cs rename to src/Controllers/ExportTool.cs index c21e9b1..6d8c348 100644 --- a/src/PriceListTools/ExportTool.cs +++ b/src/Controllers/ExportTool.cs @@ -1,9 +1,9 @@ using Microsoft.Office.Interop.Excel; using System; using System.Collections.Generic; -using RhSolutions.Interface; +using RhSolutions.Models; -namespace RhSolutions.PriceListTools +namespace RhSolutions.Controllers { internal class ExportTool : ToolBase { diff --git a/src/PriceListTools/MergeTool.cs b/src/Controllers/MergeTool.cs similarity index 94% rename from src/PriceListTools/MergeTool.cs rename to src/Controllers/MergeTool.cs index 3a945dd..dec8ff7 100644 --- a/src/PriceListTools/MergeTool.cs +++ b/src/Controllers/MergeTool.cs @@ -1,9 +1,9 @@ -using RhSolutions.Interface; +using RhSolutions.Models; using System; using System.Collections.Generic; using System.Linq; -namespace RhSolutions.PriceListTools +namespace RhSolutions.Controllers { internal class MergeTool : ToolBase { diff --git a/src/Interface/RibbonController.cs b/src/Controllers/RibbonController.cs similarity index 90% rename from src/Interface/RibbonController.cs rename to src/Controllers/RibbonController.cs index 6bbba3e..87c62e1 100644 --- a/src/Interface/RibbonController.cs +++ b/src/Controllers/RibbonController.cs @@ -1,13 +1,13 @@ using ExcelDna.Integration.CustomUI; using Microsoft.Office.Interop.Excel; -using RhSolutions.PriceListTools; +using RhSolutions.Services; using System; using System.IO; using System.Reflection; using System.Runtime.InteropServices; using System.Windows.Forms; -namespace RhSolutions.Interface +namespace RhSolutions.Controllers { [ComVisible(true)] public class RibbonController : ExcelRibbon @@ -52,7 +52,7 @@ namespace RhSolutions.Interface } public void OnSetPricePressed(IRibbonControl control) { - string path = Dialog.GetFilePath(); + string path = Models.Dialog.GetFilePath(); if (!string.IsNullOrEmpty(path)) { @@ -93,31 +93,31 @@ namespace RhSolutions.Interface "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Information); - AddIn.Excel.StatusBar = false; + RhSolutionsAddIn.Excel.StatusBar = false; return; } } public bool GetConvertEnabled(IRibbonControl control) { - if (AddIn.Excel.ActiveWorkbook == null) + if (RhSolutionsAddIn.Excel.ActiveWorkbook == null) return false; else { - Worksheet worksheet = AddIn.Excel.ActiveWorkbook.ActiveSheet; + Worksheet worksheet = RhSolutionsAddIn.Excel.ActiveWorkbook.ActiveSheet; return worksheet.IsRehauSource(); } } public bool GetExportEnabled(IRibbonControl control) { - if (AddIn.Excel.ActiveWorkbook == null) + if (RhSolutionsAddIn.Excel.ActiveWorkbook == null) return false; else { - Range selection = AddIn.Excel.Selection; + Range selection = RhSolutionsAddIn.Excel.Selection; return selection.Columns.Count == 2; } } diff --git a/src/PriceListTools/ToolBase.cs b/src/Controllers/ToolBase.cs similarity index 97% rename from src/PriceListTools/ToolBase.cs rename to src/Controllers/ToolBase.cs index d64522d..87eb9d9 100644 --- a/src/PriceListTools/ToolBase.cs +++ b/src/Controllers/ToolBase.cs @@ -1,15 +1,15 @@ using Microsoft.Office.Interop.Excel; -using RhSolutions.Interface; +using RhSolutions.Models; +using RhSolutions.Services; using System; using System.Collections.Generic; using System.Linq; -using ProgressBar = RhSolutions.Interface.ProgressBar; -namespace RhSolutions.PriceListTools +namespace RhSolutions.Controllers { internal abstract class ToolBase { - protected Application ExcelApp = AddIn.Excel; + protected Application ExcelApp = RhSolutionsAddIn.Excel; protected TargetPriceList TargetFile { get; set; } protected ResultBar ResultBar { get; set; } protected ProgressBar ProgressBar { get; set; } diff --git a/src/Interface/Dialog.cs b/src/Models/Dialog.cs similarity index 97% rename from src/Interface/Dialog.cs rename to src/Models/Dialog.cs index 992368c..abc89b8 100644 --- a/src/Interface/Dialog.cs +++ b/src/Models/Dialog.cs @@ -2,7 +2,7 @@ using System.Collections.Generic; using System.Windows.Forms; -namespace RhSolutions.Interface +namespace RhSolutions.Models { static class Dialog { diff --git a/src/PriceListTools/PriceListBase.cs b/src/Models/PriceListBase.cs similarity index 91% rename from src/PriceListTools/PriceListBase.cs rename to src/Models/PriceListBase.cs index 805cd04..95f385d 100644 --- a/src/PriceListTools/PriceListBase.cs +++ b/src/Models/PriceListBase.cs @@ -1,6 +1,6 @@ using Microsoft.Office.Interop.Excel; -namespace RhSolutions.PriceListTools +namespace RhSolutions.Models { internal abstract class PriceListBase { diff --git a/src/PriceListTools/PriceListHeaders.cs b/src/Models/PriceListHeaders.cs similarity index 91% rename from src/PriceListTools/PriceListHeaders.cs rename to src/Models/PriceListHeaders.cs index 9c09ed7..c9a8370 100644 --- a/src/PriceListTools/PriceListHeaders.cs +++ b/src/Models/PriceListHeaders.cs @@ -1,4 +1,4 @@ -namespace RhSolutions.PriceListTools +namespace RhSolutions.Models { internal static class PriceListHeaders { diff --git a/src/PriceListTools/Product.cs b/src/Models/Product.cs similarity index 95% rename from src/PriceListTools/Product.cs rename to src/Models/Product.cs index e631293..2f092d1 100644 --- a/src/PriceListTools/Product.cs +++ b/src/Models/Product.cs @@ -1,6 +1,6 @@ using System.Linq; -namespace RhSolutions.PriceListTools +namespace RhSolutions.Models { public class Product { diff --git a/src/Interface/ProgressBar.cs b/src/Models/ProgressBar.cs similarity index 83% rename from src/Interface/ProgressBar.cs rename to src/Models/ProgressBar.cs index 7217d4e..82012e5 100644 --- a/src/Interface/ProgressBar.cs +++ b/src/Models/ProgressBar.cs @@ -1,4 +1,4 @@ -namespace RhSolutions.Interface +namespace RhSolutions.Models { internal class ProgressBar : StatusbarBase { @@ -15,7 +15,7 @@ public override void Update() { - double percent = (++CurrentProgress / TaskWeight) * 100; + double percent = ++CurrentProgress / TaskWeight * 100; Excel.StatusBar = $"{Message} Выполнено {percent:#.#} %"; } } diff --git a/src/Interface/ResultBar.cs b/src/Models/ResultBar.cs similarity index 97% rename from src/Interface/ResultBar.cs rename to src/Models/ResultBar.cs index 3652738..655540c 100644 --- a/src/Interface/ResultBar.cs +++ b/src/Models/ResultBar.cs @@ -1,7 +1,7 @@ using System; using System.Text; -namespace RhSolutions.Interface +namespace RhSolutions.Models { internal class ResultBar : StatusbarBase { diff --git a/src/AddIn/Sku.cs b/src/Models/Sku.cs similarity index 98% rename from src/AddIn/Sku.cs rename to src/Models/Sku.cs index aaf5937..1c5e477 100644 --- a/src/AddIn/Sku.cs +++ b/src/Models/Sku.cs @@ -1,6 +1,6 @@ using System.Text.RegularExpressions; -namespace RhSolutions +namespace RhSolutions.Models { internal class Sku { diff --git a/src/AddIn/SkuExtensions.cs b/src/Models/SkuExtensions.cs similarity index 88% rename from src/AddIn/SkuExtensions.cs rename to src/Models/SkuExtensions.cs index 2e97406..160dc16 100644 --- a/src/AddIn/SkuExtensions.cs +++ b/src/Models/SkuExtensions.cs @@ -1,6 +1,6 @@ using System.Text.RegularExpressions; -namespace RhSolutions +namespace RhSolutions.Models { static class SkuExtensions { diff --git a/src/PriceListTools/SourcePriceList.cs b/src/Models/SourcePriceList.cs similarity index 98% rename from src/PriceListTools/SourcePriceList.cs rename to src/Models/SourcePriceList.cs index 4e43d7a..d210c10 100644 --- a/src/PriceListTools/SourcePriceList.cs +++ b/src/Models/SourcePriceList.cs @@ -3,9 +3,8 @@ using Microsoft.Office.Interop.Excel; using System; using System.Collections.Generic; using System.Linq; -using RhSolutions.Interface; -namespace RhSolutions.PriceListTools +namespace RhSolutions.Models { internal class SourcePriceList : PriceListBase { diff --git a/src/Interface/StatusbarBase.cs b/src/Models/StatusbarBase.cs similarity index 74% rename from src/Interface/StatusbarBase.cs rename to src/Models/StatusbarBase.cs index f1af972..a1be5ed 100644 --- a/src/Interface/StatusbarBase.cs +++ b/src/Models/StatusbarBase.cs @@ -4,17 +4,17 @@ using System; using System.Threading; using System.Threading.Tasks; -namespace RhSolutions.Interface +namespace RhSolutions.Models { internal abstract class StatusbarBase : IDisposable { - protected Application Excel = AddIn.Excel; + protected Application Excel = RhSolutionsAddIn.Excel; public abstract void Update(); private static void ResetStatusBar() { - AddIn.Excel.StatusBar = false; + RhSolutionsAddIn.Excel.StatusBar = false; } public void Dispose() diff --git a/src/PriceListTools/TargetPriceList.cs b/src/Models/TargetPriceList.cs similarity index 88% rename from src/PriceListTools/TargetPriceList.cs rename to src/Models/TargetPriceList.cs index e360062..4754049 100644 --- a/src/PriceListTools/TargetPriceList.cs +++ b/src/Models/TargetPriceList.cs @@ -2,7 +2,7 @@ using System; using System.Linq; -namespace RhSolutions.PriceListTools +namespace RhSolutions.Models { internal class TargetPriceList : PriceListBase { @@ -31,7 +31,7 @@ namespace RhSolutions.PriceListTools if (cells.Any(x => x == null)) { - throw new ArgumentException($"Шаблон { Name } не является прайс-листом"); + throw new ArgumentException($"Шаблон {Name} не является прайс-листом"); } } } diff --git a/src/AddIn/WorksheetExtensions.cs b/src/Models/WorksheetExtensions.cs similarity index 94% rename from src/AddIn/WorksheetExtensions.cs rename to src/Models/WorksheetExtensions.cs index b07e2c1..6b5fc3e 100644 --- a/src/AddIn/WorksheetExtensions.cs +++ b/src/Models/WorksheetExtensions.cs @@ -1,8 +1,8 @@ using Microsoft.Office.Interop.Excel; -using RhSolutions.PriceListTools; +using RhSolutions.Models; using System.Linq; -namespace RhSolutions +namespace RhSolutions.Services { public static class WorksheetExtensions { diff --git a/src/RhSolutions-AddIn.dna b/src/RhSolutions-AddIn.dna index 3b9f26a..eecb271 100644 --- a/src/RhSolutions-AddIn.dna +++ b/src/RhSolutions-AddIn.dna @@ -1,6 +1,6 @@ - +