Add Magic Tool

This commit is contained in:
Sergey Chebotar 2023-05-23 06:54:37 +03:00
parent d894c50ca3
commit 136aa7f238
3 changed files with 25 additions and 2 deletions

View File

@ -1,5 +1,4 @@
using RhSolutions.AddIn; #if !NET472
#if !NET472
using System.Runtime.Versioning; using System.Runtime.Versioning;
#endif #endif

View File

@ -0,0 +1,23 @@
#if !NET472
using System.Runtime.Versioning;
#endif
namespace RhSolutions.Tools;
internal class MagicTool : Tool
{
public MagicTool(IServiceProvider provider) : base(provider)
{
}
public override void Execute()
{
Application app = RhSolutionsAddIn.Excel.Application;
Worksheet worksheet = app.ActiveWorkbook.ActiveSheet;
_reader = _readerFactory.GetReader("Magic");
var products = _reader.ReadProducts(new[] { worksheet });
_writer = _writerFactory.GetWriter("Excel");
_writer.WriteProducts(products);
}
}

View File

@ -10,6 +10,7 @@ internal class ToolFactory
"convert" => new ConvertTool(RhSolutionsAddIn.ServiceProvider), "convert" => new ConvertTool(RhSolutionsAddIn.ServiceProvider),
"merge" => new MergeTool(RhSolutionsAddIn.ServiceProvider), "merge" => new MergeTool(RhSolutionsAddIn.ServiceProvider),
"dxfexport" => new DxfTool(RhSolutionsAddIn.ServiceProvider), "dxfexport" => new DxfTool(RhSolutionsAddIn.ServiceProvider),
"magicexport" => new MagicTool(RhSolutionsAddIn.ServiceProvider),
_ => throw new Exception("Неизвестный инструмент"), _ => throw new Exception("Неизвестный инструмент"),
}; };
return tool; return tool;