RhSolutions-AddIn/RhSolutions.AddIn/Services/WriterFactory.cs

22 lines
589 B
C#
Raw Normal View History

2023-04-17 08:49:26 +03:00
namespace RhSolutions.Services;
public class WriterFactory
{
private readonly IServiceProvider _serviceProvider;
public WriterFactory(IServiceProvider serviceProvider)
{
_serviceProvider = serviceProvider;
}
2023-04-20 09:37:07 +03:00
public IWriter GetWriter(string writerName)
2023-04-17 08:49:26 +03:00
{
2023-05-22 07:31:53 +03:00
return writerName switch
2023-04-17 08:49:26 +03:00
{
2023-05-22 07:39:48 +03:00
"Excel" => (IWriter)_serviceProvider.GetService(typeof(ExcelWriter)),
2023-05-22 07:31:53 +03:00
"Dxf" => (IWriter)_serviceProvider.GetService(typeof(DxfWriter)),
_ => (IWriter)_serviceProvider.GetService(typeof(ExcelWriter))
};
2023-04-17 08:49:26 +03:00
}
}