RhSolutions-AddIn/RhSolutions.AddIn/Services/WriterFactory.cs
2023-04-20 09:37:07 +03:00

25 lines
546 B
C#

namespace RhSolutions.Services;
public class WriterFactory
{
private readonly IServiceProvider _serviceProvider;
public WriterFactory(IServiceProvider serviceProvider)
{
_serviceProvider = serviceProvider;
}
public IWriter GetWriter(string writerName)
{
if (writerName.Equals("Dxf"))
{
return (IWriter)_serviceProvider.GetService(typeof(DxfWriter));
}
else
{
return (IWriter)_serviceProvider.GetService(typeof(ExcelWriter));
}
}
}