Fix bar disposing
This commit is contained in:
parent
f7eec55b4a
commit
dfd0db9133
@ -63,7 +63,7 @@ public class RibbonController : ExcelRibbon
|
||||
{
|
||||
try
|
||||
{
|
||||
ToolBase tool = control.Id switch
|
||||
using ToolBase tool = control.Id switch
|
||||
{
|
||||
"export" => new ExportTool(),
|
||||
"convert" => new ConvertTool(),
|
||||
|
@ -1,8 +1,9 @@
|
||||
namespace RhSolutions.Services;
|
||||
|
||||
public interface IExcelReader
|
||||
public interface IExcelReader : IDisposable
|
||||
{
|
||||
public Dictionary<Product, double> ReadProducts(Range range);
|
||||
public List<(string, Dictionary<Product, double>)> ReadProducts(IEnumerable<Worksheet> worksheets);
|
||||
public List<(string, Dictionary<Product, double>)> ReadProducts(string[] files);
|
||||
new void Dispose();
|
||||
}
|
||||
|
@ -1,7 +1,8 @@
|
||||
namespace RhSolutions.Services;
|
||||
|
||||
public interface IExcelWriter
|
||||
public interface IExcelWriter : IDisposable
|
||||
{
|
||||
public void WriteProducts(IEnumerable<(string, Dictionary<Product, double>)> products);
|
||||
public void WriteProducts(Dictionary<Product, double> products);
|
||||
new void Dispose();
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ namespace RhSolutions.Tools;
|
||||
#if !NET472
|
||||
[SupportedOSPlatform("windows")]
|
||||
#endif
|
||||
internal abstract class ToolBase
|
||||
internal abstract class ToolBase : IDisposable
|
||||
{
|
||||
protected readonly IExcelReader _reader;
|
||||
protected readonly IExcelWriter _writer;
|
||||
@ -18,5 +18,11 @@ internal abstract class ToolBase
|
||||
_writer = RhSolutionsAddIn.ServiceProvider.GetRequiredService<IExcelWriter>();
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_reader.Dispose();
|
||||
_writer.Dispose();
|
||||
}
|
||||
|
||||
public abstract void Execute();
|
||||
}
|
Loading…
Reference in New Issue
Block a user