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

25 lines
546 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
{
if (writerName.Equals("Dxf"))
{
2023-04-20 09:37:07 +03:00
return (IWriter)_serviceProvider.GetService(typeof(DxfWriter));
2023-04-17 08:49:26 +03:00
}
else
{
2023-04-20 09:37:07 +03:00
return (IWriter)_serviceProvider.GetService(typeof(ExcelWriter));
2023-04-17 08:49:26 +03:00
}
}
}