2022-10-31 04:14:42 +03:00
|
|
|
|
using Autofac;
|
|
|
|
|
using NAPS2.ImportExport.Email;
|
2022-08-21 03:50:38 +03:00
|
|
|
|
using NAPS2.ImportExport.Email.Mapi;
|
|
|
|
|
using NAPS2.ImportExport.Email.Oauth;
|
|
|
|
|
|
|
|
|
|
namespace NAPS2;
|
|
|
|
|
|
2023-12-30 08:23:45 +03:00
|
|
|
|
internal class AutofacEmailProviderFactory : IEmailProviderFactory
|
2022-08-21 03:50:38 +03:00
|
|
|
|
{
|
2022-10-31 04:14:42 +03:00
|
|
|
|
private readonly IComponentContext _container;
|
2022-08-21 03:50:38 +03:00
|
|
|
|
|
2022-10-31 04:14:42 +03:00
|
|
|
|
public AutofacEmailProviderFactory(IComponentContext container)
|
2022-08-21 03:50:38 +03:00
|
|
|
|
{
|
2022-10-31 04:14:42 +03:00
|
|
|
|
_container = container;
|
2022-08-21 03:50:38 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public IEmailProvider Create(EmailProviderType type)
|
|
|
|
|
{
|
|
|
|
|
switch (type)
|
|
|
|
|
{
|
|
|
|
|
case EmailProviderType.Gmail:
|
2022-10-31 04:14:42 +03:00
|
|
|
|
return _container.Resolve<GmailEmailProvider>();
|
2022-08-21 03:50:38 +03:00
|
|
|
|
case EmailProviderType.OutlookWeb:
|
2022-10-31 04:14:42 +03:00
|
|
|
|
return _container.Resolve<OutlookWebEmailProvider>();
|
2023-03-25 19:56:03 +03:00
|
|
|
|
case EmailProviderType.Thunderbird:
|
|
|
|
|
return _container.Resolve<ThunderbirdEmailProvider>();
|
2023-03-27 06:25:33 +03:00
|
|
|
|
case EmailProviderType.AppleMail:
|
|
|
|
|
return _container.Resolve<IAppleMailEmailProvider>();
|
2022-08-21 03:50:38 +03:00
|
|
|
|
default:
|
2022-10-31 04:14:42 +03:00
|
|
|
|
return _container.Resolve<MapiEmailProvider>();
|
2022-08-21 03:50:38 +03:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public IEmailProvider Default
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
2022-10-31 04:14:42 +03:00
|
|
|
|
var config = _container.Resolve<Naps2Config>();
|
2022-08-21 03:50:38 +03:00
|
|
|
|
var providerType = config.Get(c => c.EmailSetup.ProviderType);
|
|
|
|
|
return Create(providerType);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|