RhSolutions-AddIn/RhSolutions.AddIn/Services/WriterFactory.cs
2023-05-22 07:39:48 +03:00

22 lines
589 B
C#

namespace RhSolutions.Services;
public class WriterFactory
{
private readonly IServiceProvider _serviceProvider;
public WriterFactory(IServiceProvider serviceProvider)
{
_serviceProvider = serviceProvider;
}
public IWriter GetWriter(string writerName)
{
return writerName switch
{
"Excel" => (IWriter)_serviceProvider.GetService(typeof(ExcelWriter)),
"Dxf" => (IWriter)_serviceProvider.GetService(typeof(DxfWriter)),
_ => (IWriter)_serviceProvider.GetService(typeof(ExcelWriter))
};
}
}