Внедрить фабрики объектов вместо прямых new #14

Merged
rust merged 8 commits from t12_object_factories into main 2026-09-13 04:25:18 +03:00
6 changed files with 8 additions and 7 deletions
Showing only changes of commit c7789c0b21 - Show all commits
@@ -45,6 +45,6 @@ public sealed class AiClassifierFactory : IAiClassifierFactory
}
/// <inheritdoc />
public IAiClassifier Create() =>
IAiClassifier IAiClassifierFactory.Create() =>
new BudgetedAiClassifier(_paidClassifier, _localClassifier, _tenantLimits, _tenantContext, _logger);
}
@@ -40,5 +40,5 @@ public sealed class AiToolsFactory : IAiToolsFactory
}
/// <inheritdoc />
public IAiTools Create() => new BudgetedAiTools(_paidTools, _tenantLimits, _tenantContext, _logger);
IAiTools IAiToolsFactory.Create() => new BudgetedAiTools(_paidTools, _tenantLimits, _tenantContext, _logger);
}
@@ -35,7 +35,7 @@ public sealed class FileStorageFactory : IFileStorageFactory
}
/// <inheritdoc />
public IFileStorage Create() =>
IFileStorage IFileStorageFactory.Create() =>
_options.Minio.IsConfigured()
? new MinioFileStorage(_options.Minio, _minioLogger)
: new LocalFileStorage(_localRoot.Path);
@@ -27,5 +27,5 @@ public sealed class TenantLimitStoreFactory : ITenantLimitStoreFactory
}
/// <inheritdoc />
public ITenantLimitStore Create() => new TenantLimitStore(_dbContext, _defaults);
ITenantLimitStore ITenantLimitStoreFactory.Create() => new TenantLimitStore(_dbContext, _defaults);
}
@@ -21,5 +21,5 @@ public sealed class SecretCipherFactory : ISecretCipherFactory
}
/// <inheritdoc />
public ISecretCipher Create() => new AesGcmSecretCipher(_keyProvider.GetKey());
ISecretCipher ISecretCipherFactory.Create() => new AesGcmSecretCipher(_keyProvider.GetKey());
}
@@ -1,4 +1,5 @@
using Deal.Contracts.Integrations.Abstractions;
using Deal.Infrastructure.Integrations.Storage.Abstractions;
using Deal.Infrastructure.Integrations.Storage.Options;
using Deal.Infrastructure.Integrations.Storage.Services;
using Microsoft.Extensions.Logging.Abstractions;
@@ -14,7 +15,7 @@ public sealed class FileStorageFactoryTests
[Fact]
public void Create_MinioNotConfigured_ReturnsLocalFileStorage()
{
var factory = new FileStorageFactory(
IFileStorageFactory factory = new FileStorageFactory(
new StorageOptions(),
new LocalStorageRoot("/tmp/deal-attachments"),
NullLogger<MinioFileStorage>.Instance);
@@ -37,7 +38,7 @@ public sealed class FileStorageFactoryTests
SecretKey = "deal-secret",
},
};
var factory = new FileStorageFactory(
IFileStorageFactory factory = new FileStorageFactory(
options,
new LocalStorageRoot("/tmp/deal-attachments"),
NullLogger<MinioFileStorage>.Instance);