From 6bfd1d981bea4fd98b98cf8b8a2a0ebb176f5a6a Mon Sep 17 00:00:00 2001 From: Sergey Chebotar Date: Thu, 20 Apr 2023 09:37:07 +0300 Subject: [PATCH] Simplify class names --- RhSolutions.AddIn/AddIn/RhSolutionsAddIn.cs | 16 ++++++++-------- ...dInConfiguration.cs => AddInConfiguration.cs} | 4 ++-- .../{RhDatabaseClient.cs => DatabaseClient.cs} | 4 ++-- .../Services/{RhDxfWriter.cs => DxfWriter.cs} | 4 ++-- .../{RhExcelReader.cs => ExcelReader.cs} | 4 ++-- .../{RhExcelWriter.cs => ExcelWriter.cs} | 4 ++-- .../{ExcelFileDialog.cs => FileDialog.cs} | 4 ++-- .../Services/{IExcelReader.cs => IReader.cs} | 2 +- .../Services/{IExcelWriter.cs => IWriter.cs} | 2 +- RhSolutions.AddIn/Services/WriterFactory.cs | 6 +++--- RhSolutions.AddIn/Tools/Tool.cs | 6 +++--- RhSolutions.Tests/CanReadProducts.cs | 4 ++-- 12 files changed, 30 insertions(+), 30 deletions(-) rename RhSolutions.AddIn/Services/{RhAddInConfiguration.cs => AddInConfiguration.cs} (95%) rename RhSolutions.AddIn/Services/{RhDatabaseClient.cs => DatabaseClient.cs} (92%) rename RhSolutions.AddIn/Services/{RhDxfWriter.cs => DxfWriter.cs} (99%) rename RhSolutions.AddIn/Services/{RhExcelReader.cs => ExcelReader.cs} (97%) rename RhSolutions.AddIn/Services/{RhExcelWriter.cs => ExcelWriter.cs} (98%) rename RhSolutions.AddIn/Services/{ExcelFileDialog.cs => FileDialog.cs} (92%) rename RhSolutions.AddIn/Services/{IExcelReader.cs => IReader.cs} (87%) rename RhSolutions.AddIn/Services/{IExcelWriter.cs => IWriter.cs} (83%) diff --git a/RhSolutions.AddIn/AddIn/RhSolutionsAddIn.cs b/RhSolutions.AddIn/AddIn/RhSolutionsAddIn.cs index ba9cd2f..0301535 100644 --- a/RhSolutions.AddIn/AddIn/RhSolutionsAddIn.cs +++ b/RhSolutions.AddIn/AddIn/RhSolutionsAddIn.cs @@ -20,16 +20,16 @@ public sealed class RhSolutionsAddIn : IExcelAddIn Services.AddHttpClient() .AddSingleton((Application)ExcelDnaUtil.Application) - .AddSingleton() - .AddSingleton() - .AddTransient() - .AddTransient(); + .AddSingleton() + .AddSingleton() + .AddTransient() + .AddTransient(); Services.AddSingleton(); - Services.AddTransient() - .AddTransient(s => s.GetService()); - Services.AddTransient() - .AddTransient(s => s.GetService()); + Services.AddTransient() + .AddTransient(s => s.GetService()); + Services.AddTransient() + .AddTransient(s => s.GetService()); Services.AddSingleton(); diff --git a/RhSolutions.AddIn/Services/RhAddInConfiguration.cs b/RhSolutions.AddIn/Services/AddInConfiguration.cs similarity index 95% rename from RhSolutions.AddIn/Services/RhAddInConfiguration.cs rename to RhSolutions.AddIn/Services/AddInConfiguration.cs index e9e393b..363c3f3 100644 --- a/RhSolutions.AddIn/Services/RhAddInConfiguration.cs +++ b/RhSolutions.AddIn/Services/AddInConfiguration.cs @@ -3,11 +3,11 @@ using System.IO; namespace RhSolutions.Services; -public class RhAddInConfiguration : ApplicationSettingsBase, IAddInConfiguration +public class AddInConfiguration : ApplicationSettingsBase, IAddInConfiguration { private readonly Dictionary _priceListHeaders; - public RhAddInConfiguration() + public AddInConfiguration() { _priceListHeaders = new Dictionary() { diff --git a/RhSolutions.AddIn/Services/RhDatabaseClient.cs b/RhSolutions.AddIn/Services/DatabaseClient.cs similarity index 92% rename from RhSolutions.AddIn/Services/RhDatabaseClient.cs rename to RhSolutions.AddIn/Services/DatabaseClient.cs index 520915d..2e73304 100644 --- a/RhSolutions.AddIn/Services/RhDatabaseClient.cs +++ b/RhSolutions.AddIn/Services/DatabaseClient.cs @@ -5,12 +5,12 @@ using System.Threading.Tasks; namespace RhSolutions.Services; -public class RhDatabaseClient : IDatabaseClient +public class DatabaseClient : IDatabaseClient { private readonly IServiceProvider serviceProvider; public HttpStatusCode StatusCode { get; private set; } - public RhDatabaseClient(IServiceProvider provider) + public DatabaseClient(IServiceProvider provider) { this.serviceProvider = provider; } diff --git a/RhSolutions.AddIn/Services/RhDxfWriter.cs b/RhSolutions.AddIn/Services/DxfWriter.cs similarity index 99% rename from RhSolutions.AddIn/Services/RhDxfWriter.cs rename to RhSolutions.AddIn/Services/DxfWriter.cs index 49e3013..9909fb6 100644 --- a/RhSolutions.AddIn/Services/RhDxfWriter.cs +++ b/RhSolutions.AddIn/Services/DxfWriter.cs @@ -8,14 +8,14 @@ using Line = netDxf.Entities.Line; namespace RhSolutions.Services; -public class RhDxfWriter : IExcelWriter +public class DxfWriter : IWriter { private readonly string file; private readonly DxfDocument doc; private Dictionary productDict; private readonly Block tableBlock; - public RhDxfWriter() + public DxfWriter() { string filepath = RhSolutionsAddIn.Excel.ActiveWorkbook.Path; string filename = Path.GetFileNameWithoutExtension(RhSolutionsAddIn.Excel.ActiveWorkbook.Name); diff --git a/RhSolutions.AddIn/Services/RhExcelReader.cs b/RhSolutions.AddIn/Services/ExcelReader.cs similarity index 97% rename from RhSolutions.AddIn/Services/RhExcelReader.cs rename to RhSolutions.AddIn/Services/ExcelReader.cs index fd3163a..5cc5e86 100644 --- a/RhSolutions.AddIn/Services/RhExcelReader.cs +++ b/RhSolutions.AddIn/Services/ExcelReader.cs @@ -9,13 +9,13 @@ namespace RhSolutions.Services; #if !NET472 [SupportedOSPlatform("windows")] #endif -public class RhExcelReader : IExcelReader, IDisposable +public class ExcelReader : IReader, IDisposable { private ProgressBar _progressBar; private readonly Dictionary headers; private readonly Application _application; - public RhExcelReader(Application application, IAddInConfiguration configuration) + public ExcelReader(Application application, IAddInConfiguration configuration) { _application = application; headers = configuration.GetPriceListHeaders(); diff --git a/RhSolutions.AddIn/Services/RhExcelWriter.cs b/RhSolutions.AddIn/Services/ExcelWriter.cs similarity index 98% rename from RhSolutions.AddIn/Services/RhExcelWriter.cs rename to RhSolutions.AddIn/Services/ExcelWriter.cs index 2916dc2..445e2d5 100644 --- a/RhSolutions.AddIn/Services/RhExcelWriter.cs +++ b/RhSolutions.AddIn/Services/ExcelWriter.cs @@ -9,7 +9,7 @@ namespace RhSolutions.Services; #if !NET472 [SupportedOSPlatform("windows")] #endif -public class RhExcelWriter : IExcelWriter, IDisposable +public class ExcelWriter : IWriter, IDisposable { private readonly Application _application; private Worksheet _worksheet; @@ -24,7 +24,7 @@ public class RhExcelWriter : IExcelWriter, IDisposable _nameCell, _oldSkuCell; - public RhExcelWriter(Application application, IAddInConfiguration configuration) + public ExcelWriter(Application application, IAddInConfiguration configuration) { _application = application; _pricelistPath = configuration.GetPriceListPath(); diff --git a/RhSolutions.AddIn/Services/ExcelFileDialog.cs b/RhSolutions.AddIn/Services/FileDialog.cs similarity index 92% rename from RhSolutions.AddIn/Services/ExcelFileDialog.cs rename to RhSolutions.AddIn/Services/FileDialog.cs index 9e70d46..f211307 100644 --- a/RhSolutions.AddIn/Services/ExcelFileDialog.cs +++ b/RhSolutions.AddIn/Services/FileDialog.cs @@ -1,10 +1,10 @@ namespace RhSolutions.Services; -public class ExcelFileDialog : IFileDialog +public class FileDialog : IFileDialog { private Application _application; - public ExcelFileDialog(Application application) + public FileDialog(Application application) { _application = application; } diff --git a/RhSolutions.AddIn/Services/IExcelReader.cs b/RhSolutions.AddIn/Services/IReader.cs similarity index 87% rename from RhSolutions.AddIn/Services/IExcelReader.cs rename to RhSolutions.AddIn/Services/IReader.cs index 897d452..a2474cc 100644 --- a/RhSolutions.AddIn/Services/IExcelReader.cs +++ b/RhSolutions.AddIn/Services/IReader.cs @@ -1,6 +1,6 @@ namespace RhSolutions.Services; -public interface IExcelReader : IDisposable +public interface IReader : IDisposable { public Dictionary ReadProducts(Range range); public List<(string, Dictionary)> ReadProducts(IEnumerable worksheets); diff --git a/RhSolutions.AddIn/Services/IExcelWriter.cs b/RhSolutions.AddIn/Services/IWriter.cs similarity index 83% rename from RhSolutions.AddIn/Services/IExcelWriter.cs rename to RhSolutions.AddIn/Services/IWriter.cs index ea6bf5a..fd41fd7 100644 --- a/RhSolutions.AddIn/Services/IExcelWriter.cs +++ b/RhSolutions.AddIn/Services/IWriter.cs @@ -1,6 +1,6 @@ namespace RhSolutions.Services; -public interface IExcelWriter : IDisposable +public interface IWriter : IDisposable { public void WriteProducts(IEnumerable<(string, Dictionary)> products); public void WriteProducts(Dictionary products); diff --git a/RhSolutions.AddIn/Services/WriterFactory.cs b/RhSolutions.AddIn/Services/WriterFactory.cs index 8238629..3193712 100644 --- a/RhSolutions.AddIn/Services/WriterFactory.cs +++ b/RhSolutions.AddIn/Services/WriterFactory.cs @@ -9,16 +9,16 @@ public class WriterFactory _serviceProvider = serviceProvider; } - public IExcelWriter GetWriter(string writerName) + public IWriter GetWriter(string writerName) { if (writerName.Equals("Dxf")) { - return (IExcelWriter)_serviceProvider.GetService(typeof(RhDxfWriter)); + return (IWriter)_serviceProvider.GetService(typeof(DxfWriter)); } else { - return (IExcelWriter)_serviceProvider.GetService(typeof(RhExcelWriter)); + return (IWriter)_serviceProvider.GetService(typeof(ExcelWriter)); } } } diff --git a/RhSolutions.AddIn/Tools/Tool.cs b/RhSolutions.AddIn/Tools/Tool.cs index 2869dff..c9ae815 100644 --- a/RhSolutions.AddIn/Tools/Tool.cs +++ b/RhSolutions.AddIn/Tools/Tool.cs @@ -9,13 +9,13 @@ namespace RhSolutions.Tools; #endif internal abstract class Tool : IDisposable { - protected readonly IExcelReader _reader; + protected readonly IReader _reader; protected readonly WriterFactory _writerFactory; - protected IExcelWriter _writer; + protected IWriter _writer; public Tool(IServiceProvider provider) { - _reader = provider.GetRequiredService(); + _reader = provider.GetRequiredService(); _writerFactory = provider.GetRequiredService(); } diff --git a/RhSolutions.Tests/CanReadProducts.cs b/RhSolutions.Tests/CanReadProducts.cs index e9be68c..fd33a69 100644 --- a/RhSolutions.Tests/CanReadProducts.cs +++ b/RhSolutions.Tests/CanReadProducts.cs @@ -7,7 +7,7 @@ namespace RhSolutions.Tests; public class CanReadProducts : IDisposable { private RhSolutionsAddIn _addIn; - private IExcelReader _reader; + private IReader _reader; private Workbook _testWorkbook; public CanReadProducts() @@ -15,7 +15,7 @@ public class CanReadProducts : IDisposable _addIn = new(); _testWorkbook = Util.Application.Workbooks.Add(); _addIn.AutoOpen(); - _reader = RhSolutionsAddIn.ServiceProvider.GetRequiredService(); + _reader = RhSolutionsAddIn.ServiceProvider.GetRequiredService(); } [ExcelFact]