Simplify class names

This commit is contained in:
Sergey Chebotar 2023-04-20 09:37:07 +03:00
parent a6caea1787
commit 6bfd1d981b
12 changed files with 30 additions and 30 deletions

View File

@ -20,16 +20,16 @@ public sealed class RhSolutionsAddIn : IExcelAddIn
Services.AddHttpClient() Services.AddHttpClient()
.AddSingleton((Application)ExcelDnaUtil.Application) .AddSingleton((Application)ExcelDnaUtil.Application)
.AddSingleton<IAddInConfiguration, RhAddInConfiguration>() .AddSingleton<IAddInConfiguration, AddInConfiguration>()
.AddSingleton<IDatabaseClient, RhDatabaseClient>() .AddSingleton<IDatabaseClient, DatabaseClient>()
.AddTransient<IFileDialog, ExcelFileDialog>() .AddTransient<IFileDialog, FileDialog>()
.AddTransient<IExcelReader, RhExcelReader>(); .AddTransient<IReader, ExcelReader>();
Services.AddSingleton<WriterFactory>(); Services.AddSingleton<WriterFactory>();
Services.AddTransient<RhExcelWriter>() Services.AddTransient<ExcelWriter>()
.AddTransient<IExcelWriter, RhExcelWriter>(s => s.GetService<RhExcelWriter>()); .AddTransient<IWriter, ExcelWriter>(s => s.GetService<ExcelWriter>());
Services.AddTransient<RhDxfWriter>() Services.AddTransient<DxfWriter>()
.AddTransient<IExcelWriter, RhDxfWriter>(s => s.GetService<RhDxfWriter>()); .AddTransient<IWriter, DxfWriter>(s => s.GetService<DxfWriter>());
Services.AddSingleton<ToolFactory>(); Services.AddSingleton<ToolFactory>();

View File

@ -3,11 +3,11 @@ using System.IO;
namespace RhSolutions.Services; namespace RhSolutions.Services;
public class RhAddInConfiguration : ApplicationSettingsBase, IAddInConfiguration public class AddInConfiguration : ApplicationSettingsBase, IAddInConfiguration
{ {
private readonly Dictionary<string, string> _priceListHeaders; private readonly Dictionary<string, string> _priceListHeaders;
public RhAddInConfiguration() public AddInConfiguration()
{ {
_priceListHeaders = new Dictionary<string, string>() _priceListHeaders = new Dictionary<string, string>()
{ {

View File

@ -5,12 +5,12 @@ using System.Threading.Tasks;
namespace RhSolutions.Services; namespace RhSolutions.Services;
public class RhDatabaseClient : IDatabaseClient public class DatabaseClient : IDatabaseClient
{ {
private readonly IServiceProvider serviceProvider; private readonly IServiceProvider serviceProvider;
public HttpStatusCode StatusCode { get; private set; } public HttpStatusCode StatusCode { get; private set; }
public RhDatabaseClient(IServiceProvider provider) public DatabaseClient(IServiceProvider provider)
{ {
this.serviceProvider = provider; this.serviceProvider = provider;
} }

View File

@ -8,14 +8,14 @@ using Line = netDxf.Entities.Line;
namespace RhSolutions.Services; namespace RhSolutions.Services;
public class RhDxfWriter : IExcelWriter public class DxfWriter : IWriter
{ {
private readonly string file; private readonly string file;
private readonly DxfDocument doc; private readonly DxfDocument doc;
private Dictionary<Product, double> productDict; private Dictionary<Product, double> productDict;
private readonly Block tableBlock; private readonly Block tableBlock;
public RhDxfWriter() public DxfWriter()
{ {
string filepath = RhSolutionsAddIn.Excel.ActiveWorkbook.Path; string filepath = RhSolutionsAddIn.Excel.ActiveWorkbook.Path;
string filename = Path.GetFileNameWithoutExtension(RhSolutionsAddIn.Excel.ActiveWorkbook.Name); string filename = Path.GetFileNameWithoutExtension(RhSolutionsAddIn.Excel.ActiveWorkbook.Name);

View File

@ -9,13 +9,13 @@ namespace RhSolutions.Services;
#if !NET472 #if !NET472
[SupportedOSPlatform("windows")] [SupportedOSPlatform("windows")]
#endif #endif
public class RhExcelReader : IExcelReader, IDisposable public class ExcelReader : IReader, IDisposable
{ {
private ProgressBar _progressBar; private ProgressBar _progressBar;
private readonly Dictionary<string, string> headers; private readonly Dictionary<string, string> headers;
private readonly Application _application; private readonly Application _application;
public RhExcelReader(Application application, IAddInConfiguration configuration) public ExcelReader(Application application, IAddInConfiguration configuration)
{ {
_application = application; _application = application;
headers = configuration.GetPriceListHeaders(); headers = configuration.GetPriceListHeaders();

View File

@ -9,7 +9,7 @@ namespace RhSolutions.Services;
#if !NET472 #if !NET472
[SupportedOSPlatform("windows")] [SupportedOSPlatform("windows")]
#endif #endif
public class RhExcelWriter : IExcelWriter, IDisposable public class ExcelWriter : IWriter, IDisposable
{ {
private readonly Application _application; private readonly Application _application;
private Worksheet _worksheet; private Worksheet _worksheet;
@ -24,7 +24,7 @@ public class RhExcelWriter : IExcelWriter, IDisposable
_nameCell, _nameCell,
_oldSkuCell; _oldSkuCell;
public RhExcelWriter(Application application, IAddInConfiguration configuration) public ExcelWriter(Application application, IAddInConfiguration configuration)
{ {
_application = application; _application = application;
_pricelistPath = configuration.GetPriceListPath(); _pricelistPath = configuration.GetPriceListPath();

View File

@ -1,10 +1,10 @@
namespace RhSolutions.Services; namespace RhSolutions.Services;
public class ExcelFileDialog : IFileDialog public class FileDialog : IFileDialog
{ {
private Application _application; private Application _application;
public ExcelFileDialog(Application application) public FileDialog(Application application)
{ {
_application = application; _application = application;
} }

View File

@ -1,6 +1,6 @@
namespace RhSolutions.Services; namespace RhSolutions.Services;
public interface IExcelReader : IDisposable public interface IReader : IDisposable
{ {
public Dictionary<Product, double> ReadProducts(Range range); public Dictionary<Product, double> ReadProducts(Range range);
public List<(string, Dictionary<Product, double>)> ReadProducts(IEnumerable<Worksheet> worksheets); public List<(string, Dictionary<Product, double>)> ReadProducts(IEnumerable<Worksheet> worksheets);

View File

@ -1,6 +1,6 @@
namespace RhSolutions.Services; namespace RhSolutions.Services;
public interface IExcelWriter : IDisposable public interface IWriter : IDisposable
{ {
public void WriteProducts(IEnumerable<(string, Dictionary<Product, double>)> products); public void WriteProducts(IEnumerable<(string, Dictionary<Product, double>)> products);
public void WriteProducts(Dictionary<Product, double> products); public void WriteProducts(Dictionary<Product, double> products);

View File

@ -9,16 +9,16 @@ public class WriterFactory
_serviceProvider = serviceProvider; _serviceProvider = serviceProvider;
} }
public IExcelWriter GetWriter(string writerName) public IWriter GetWriter(string writerName)
{ {
if (writerName.Equals("Dxf")) if (writerName.Equals("Dxf"))
{ {
return (IExcelWriter)_serviceProvider.GetService(typeof(RhDxfWriter)); return (IWriter)_serviceProvider.GetService(typeof(DxfWriter));
} }
else else
{ {
return (IExcelWriter)_serviceProvider.GetService(typeof(RhExcelWriter)); return (IWriter)_serviceProvider.GetService(typeof(ExcelWriter));
} }
} }
} }

View File

@ -9,13 +9,13 @@ namespace RhSolutions.Tools;
#endif #endif
internal abstract class Tool : IDisposable internal abstract class Tool : IDisposable
{ {
protected readonly IExcelReader _reader; protected readonly IReader _reader;
protected readonly WriterFactory _writerFactory; protected readonly WriterFactory _writerFactory;
protected IExcelWriter _writer; protected IWriter _writer;
public Tool(IServiceProvider provider) public Tool(IServiceProvider provider)
{ {
_reader = provider.GetRequiredService<IExcelReader>(); _reader = provider.GetRequiredService<IReader>();
_writerFactory = provider.GetRequiredService<WriterFactory>(); _writerFactory = provider.GetRequiredService<WriterFactory>();
} }

View File

@ -7,7 +7,7 @@ namespace RhSolutions.Tests;
public class CanReadProducts : IDisposable public class CanReadProducts : IDisposable
{ {
private RhSolutionsAddIn _addIn; private RhSolutionsAddIn _addIn;
private IExcelReader _reader; private IReader _reader;
private Workbook _testWorkbook; private Workbook _testWorkbook;
public CanReadProducts() public CanReadProducts()
@ -15,7 +15,7 @@ public class CanReadProducts : IDisposable
_addIn = new(); _addIn = new();
_testWorkbook = Util.Application.Workbooks.Add(); _testWorkbook = Util.Application.Workbooks.Add();
_addIn.AutoOpen(); _addIn.AutoOpen();
_reader = RhSolutionsAddIn.ServiceProvider.GetRequiredService<IExcelReader>(); _reader = RhSolutionsAddIn.ServiceProvider.GetRequiredService<IReader>();
} }
[ExcelFact] [ExcelFact]