RhSolutions-AddIn/RhSolutions.AddIn/Tools/ToolFactory.cs
2023-06-21 07:11:31 +03:00

24 lines
1.0 KiB
C#

namespace RhSolutions.Tools;
internal class ToolFactory
{
static ReaderFactory readerFactory = RhSolutionsAddIn.ServiceProvider.GetService<ReaderFactory>();
static WriterFactory writerFactory = RhSolutionsAddIn.ServiceProvider.GetService<WriterFactory>();
static ISleevesCalculator sleevesCaluculator = RhSolutionsAddIn.ServiceProvider.GetService<ISleevesCalculator>();
public Tool GetTool(string toolName)
{
Tool tool = toolName switch
{
"export" => new ExportTool(readerFactory, writerFactory),
"convert" => new ConvertTool(readerFactory, writerFactory),
"merge" => new MergeTool(readerFactory, writerFactory),
"dxfexport" => new DxfTool(readerFactory, writerFactory),
"guess" => new GuessTool(readerFactory, writerFactory),
"fillsleeves" => new SleevesTool(readerFactory, writerFactory, sleevesCaluculator),
_ => throw new Exception($"Неизвестный инструмент {toolName}"),
};
return tool;
}
}