file scoped namespaces (#565)

This commit is contained in:
Aleh Khantsevich
2025-02-16 11:54:23 +01:00
committed by GitHub
parent cf9869b71e
commit 3ddc1a6229
617 changed files with 32107 additions and 32721 deletions

View File

@@ -5,54 +5,53 @@ using Wino.Core.Domain.Interfaces;
using Wino.Core.Domain.Models.Connectivity;
using Wino.Core.Integration;
namespace Wino.Core.Services
namespace Wino.Core.Services;
public class ImapTestService : IImapTestService
{
public class ImapTestService : IImapTestService
public const string ProtocolLogFileName = "ImapProtocolLog.log";
private readonly IPreferencesService _preferencesService;
private readonly IApplicationConfiguration _appInitializerService;
private Stream _protocolLogStream;
public ImapTestService(IPreferencesService preferencesService, IApplicationConfiguration appInitializerService)
{
public const string ProtocolLogFileName = "ImapProtocolLog.log";
_preferencesService = preferencesService;
_appInitializerService = appInitializerService;
}
private readonly IPreferencesService _preferencesService;
private readonly IApplicationConfiguration _appInitializerService;
private void EnsureProtocolLogFileExists()
{
// Create new file for protocol logger.
var localAppFolderPath = _appInitializerService.ApplicationDataFolderPath;
private Stream _protocolLogStream;
var logFile = Path.Combine(localAppFolderPath, ProtocolLogFileName);
public ImapTestService(IPreferencesService preferencesService, IApplicationConfiguration appInitializerService)
if (File.Exists(logFile))
File.Delete(logFile);
_protocolLogStream = File.Create(logFile);
}
public async Task TestImapConnectionAsync(CustomServerInformation serverInformation, bool allowSSLHandShake)
{
EnsureProtocolLogFileExists();
var poolOptions = ImapClientPoolOptions.CreateTestPool(serverInformation, _protocolLogStream);
var clientPool = new ImapClientPool(poolOptions)
{
_preferencesService = preferencesService;
_appInitializerService = appInitializerService;
}
ThrowOnSSLHandshakeCallback = !allowSSLHandShake
};
private void EnsureProtocolLogFileExists()
using (clientPool)
{
// Create new file for protocol logger.
var localAppFolderPath = _appInitializerService.ApplicationDataFolderPath;
// This call will make sure that everything is authenticated + connected successfully.
var client = await clientPool.GetClientAsync();
var logFile = Path.Combine(localAppFolderPath, ProtocolLogFileName);
if (File.Exists(logFile))
File.Delete(logFile);
_protocolLogStream = File.Create(logFile);
}
public async Task TestImapConnectionAsync(CustomServerInformation serverInformation, bool allowSSLHandShake)
{
EnsureProtocolLogFileExists();
var poolOptions = ImapClientPoolOptions.CreateTestPool(serverInformation, _protocolLogStream);
var clientPool = new ImapClientPool(poolOptions)
{
ThrowOnSSLHandshakeCallback = !allowSSLHandShake
};
using (clientPool)
{
// This call will make sure that everything is authenticated + connected successfully.
var client = await clientPool.GetClientAsync();
clientPool.Release(client);
}
clientPool.Release(client);
}
}
}