Renamed image creators

This commit is contained in:
MaddoScientisto 2026-02-21 15:53:52 +01:00
commit c70ab9e5de
12 changed files with 50 additions and 50 deletions

View file

@ -22,7 +22,7 @@ public class ChunkSizeBenchmarks
{ {
private string _sourceDirectory; private string _sourceDirectory;
private string _destinationDirectory; private string _destinationDirectory;
private ImageCreationStuff _imageCreationStuff; private ImageCreationService _imageCreationStuff;
private PicSettings _picSettings; private PicSettings _picSettings;
[Params(100)] [Params(100)]
@ -49,8 +49,8 @@ public class ChunkSizeBenchmarks
builder.SetMinimumLevel(LogLevel.Warning); builder.SetMinimumLevel(LogLevel.Warning);
}); });
var logger = loggerFactory.CreateLogger<ImageCreationStuff>(); var logger = loggerFactory.CreateLogger<ImageCreationService>();
var imageCreatorLogger = loggerFactory.CreateLogger<ImageCreatorSharp>(); var imageCreatorLogger = loggerFactory.CreateLogger<ImageCreatorGDI>();
_picSettings = new PicSettings _picSettings = new PicSettings
{ {
@ -75,8 +75,8 @@ public class ChunkSizeBenchmarks
Trasparenza = 100 Trasparenza = 100
}; };
var imageCreatorService = new ImageCreatorSharp(_picSettings, imageCreatorLogger); var imageCreatorService = new ImageCreatorGDI(_picSettings, imageCreatorLogger);
_imageCreationStuff = new ImageCreationStuff(logger, _picSettings, imageCreatorService); _imageCreationStuff = new ImageCreationService(logger, _picSettings, imageCreatorService);
} }
[GlobalCleanup] [GlobalCleanup]
@ -109,7 +109,7 @@ public class ChunkSizeBenchmarks
[Benchmark] [Benchmark]
public async Task ProcessWithVariableChunkSize() public async Task ProcessWithVariableChunkSize()
{ {
var options = new ImageCreationStuff.Options var options = new ImageCreationService.Options
{ {
SourcePath = _sourceDirectory, SourcePath = _sourceDirectory,
DestinationPath = _destinationDirectory, DestinationPath = _destinationDirectory,

View file

@ -22,10 +22,10 @@ public class ImageProcessingBenchmarks
{ {
private string _sourceDirectory; private string _sourceDirectory;
private string _destinationDirectory; private string _destinationDirectory;
private ImageCreationStuff _imageCreationStuff; private ImageCreationService _imageCreationStuff;
private PicSettings _picSettings; private PicSettings _picSettings;
private ILogger<ImageCreationStuff> _logger; private ILogger<ImageCreationService> _logger;
private ILogger<ImageCreatorSharp> _imageCreatorLogger; private ILogger<ImageCreatorGDI> _imageCreatorLogger;
[Params(10, 50, 100)] [Params(10, 50, 100)]
public int ImageCount { get; set; } public int ImageCount { get; set; }
@ -54,8 +54,8 @@ public class ImageProcessingBenchmarks
builder.SetMinimumLevel(LogLevel.Warning); // Reduce noise during benchmarks builder.SetMinimumLevel(LogLevel.Warning); // Reduce noise during benchmarks
}); });
_logger = loggerFactory.CreateLogger<ImageCreationStuff>(); _logger = loggerFactory.CreateLogger<ImageCreationService>();
_imageCreatorLogger = loggerFactory.CreateLogger<ImageCreatorSharp>(); _imageCreatorLogger = loggerFactory.CreateLogger<ImageCreatorGDI>();
// Setup PicSettings with default values // Setup PicSettings with default values
_picSettings = new PicSettings _picSettings = new PicSettings
@ -81,8 +81,8 @@ public class ImageProcessingBenchmarks
Trasparenza = 100 Trasparenza = 100
}; };
var imageCreatorService = new ImageCreatorSharp(_picSettings, _imageCreatorLogger); var imageCreatorService = new ImageCreatorGDI(_picSettings, _imageCreatorLogger);
_imageCreationStuff = new ImageCreationStuff(_logger, _picSettings, imageCreatorService); _imageCreationStuff = new ImageCreationService(_logger, _picSettings, imageCreatorService);
} }
[GlobalCleanup] [GlobalCleanup]
@ -117,7 +117,7 @@ public class ImageProcessingBenchmarks
[Benchmark(Description = "Process images in parallel with chunking")] [Benchmark(Description = "Process images in parallel with chunking")]
public async Task ProcessImagesParallelWithChunks() public async Task ProcessImagesParallelWithChunks()
{ {
var options = new ImageCreationStuff.Options var options = new ImageCreationService.Options
{ {
SourcePath = _sourceDirectory, SourcePath = _sourceDirectory,
DestinationPath = _destinationDirectory, DestinationPath = _destinationDirectory,
@ -139,7 +139,7 @@ public class ImageProcessingBenchmarks
[Benchmark(Description = "Process images in parallel without chunking")] [Benchmark(Description = "Process images in parallel without chunking")]
public async Task ProcessImagesParallelWithoutChunks() public async Task ProcessImagesParallelWithoutChunks()
{ {
var options = new ImageCreationStuff.Options var options = new ImageCreationService.Options
{ {
SourcePath = _sourceDirectory, SourcePath = _sourceDirectory,
DestinationPath = _destinationDirectory, DestinationPath = _destinationDirectory,
@ -161,7 +161,7 @@ public class ImageProcessingBenchmarks
[Benchmark(Description = "Process images linearly")] [Benchmark(Description = "Process images linearly")]
public async Task ProcessImagesLinear() public async Task ProcessImagesLinear()
{ {
var options = new ImageCreationStuff.Options var options = new ImageCreationService.Options
{ {
SourcePath = _sourceDirectory, SourcePath = _sourceDirectory,
DestinationPath = _destinationDirectory, DestinationPath = _destinationDirectory,

View file

@ -22,7 +22,7 @@ public class ImageSizeBenchmarks
{ {
private string _sourceDirectory; private string _sourceDirectory;
private string _destinationDirectory; private string _destinationDirectory;
private ImageCreationStuff _imageCreationStuff; private ImageCreationService _imageCreationStuff;
private PicSettings _picSettings; private PicSettings _picSettings;
[Params(50)] [Params(50)]
@ -58,8 +58,8 @@ public class ImageSizeBenchmarks
builder.SetMinimumLevel(LogLevel.Warning); builder.SetMinimumLevel(LogLevel.Warning);
}); });
var logger = loggerFactory.CreateLogger<ImageCreationStuff>(); var logger = loggerFactory.CreateLogger<ImageCreationService>();
var imageCreatorLogger = loggerFactory.CreateLogger<ImageCreatorSharp>(); var imageCreatorLogger = loggerFactory.CreateLogger<ImageCreatorGDI>();
_picSettings = new PicSettings _picSettings = new PicSettings
{ {
@ -84,8 +84,8 @@ public class ImageSizeBenchmarks
Trasparenza = 100 Trasparenza = 100
}; };
var imageCreatorService = new ImageCreatorSharp(_picSettings, imageCreatorLogger); var imageCreatorService = new ImageCreatorGDI(_picSettings, imageCreatorLogger);
_imageCreationStuff = new ImageCreationStuff(logger, _picSettings, imageCreatorService); _imageCreationStuff = new ImageCreationService(logger, _picSettings, imageCreatorService);
} }
private static (int width, int height) GetDimensions(ImageSize size) private static (int width, int height) GetDimensions(ImageSize size)
@ -130,7 +130,7 @@ public class ImageSizeBenchmarks
[Benchmark] [Benchmark]
public async Task ProcessDifferentImageSizes() public async Task ProcessDifferentImageSizes()
{ {
var options = new ImageCreationStuff.Options var options = new ImageCreationService.Options
{ {
SourcePath = _sourceDirectory, SourcePath = _sourceDirectory,
DestinationPath = _destinationDirectory, DestinationPath = _destinationDirectory,

View file

@ -22,7 +22,7 @@ public class StressTestBenchmark
{ {
private string _sourceDirectory; private string _sourceDirectory;
private string _destinationDirectory; private string _destinationDirectory;
private ImageCreationStuff _imageCreationStuff; private ImageCreationService _imageCreationStuff;
private PicSettings _picSettings; private PicSettings _picSettings;
[Params(500, 1000)] [Params(500, 1000)]
@ -49,8 +49,8 @@ public class StressTestBenchmark
builder.SetMinimumLevel(LogLevel.Warning); builder.SetMinimumLevel(LogLevel.Warning);
}); });
var logger = loggerFactory.CreateLogger<ImageCreationStuff>(); var logger = loggerFactory.CreateLogger<ImageCreationService>();
var imageCreatorLogger = loggerFactory.CreateLogger<ImageCreatorSharp>(); var imageCreatorLogger = loggerFactory.CreateLogger<ImageCreatorGDI>();
_picSettings = new PicSettings _picSettings = new PicSettings
{ {
@ -75,8 +75,8 @@ public class StressTestBenchmark
Trasparenza = 100 Trasparenza = 100
}; };
var imageCreatorService = new ImageCreatorSharp(_picSettings, imageCreatorLogger); var imageCreatorService = new ImageCreatorGDI(_picSettings, imageCreatorLogger);
_imageCreationStuff = new ImageCreationStuff(logger, _picSettings, imageCreatorService); _imageCreationStuff = new ImageCreationService(logger, _picSettings, imageCreatorService);
Console.WriteLine($"[STRESS TEST] Setup complete. Ready to process {ImageCount} images."); Console.WriteLine($"[STRESS TEST] Setup complete. Ready to process {ImageCount} images.");
} }
@ -113,7 +113,7 @@ public class StressTestBenchmark
[Benchmark(Description = "Stress test with optimal settings")] [Benchmark(Description = "Stress test with optimal settings")]
public async Task StressTestOptimalSettings() public async Task StressTestOptimalSettings()
{ {
var options = new ImageCreationStuff.Options var options = new ImageCreationService.Options
{ {
SourcePath = _sourceDirectory, SourcePath = _sourceDirectory,
DestinationPath = _destinationDirectory, DestinationPath = _destinationDirectory,
@ -143,7 +143,7 @@ public class StressTestBenchmark
[Benchmark(Description = "Stress test with aggressive memory management")] [Benchmark(Description = "Stress test with aggressive memory management")]
public async Task StressTestAggressiveMemoryManagement() public async Task StressTestAggressiveMemoryManagement()
{ {
var options = new ImageCreationStuff.Options var options = new ImageCreationService.Options
{ {
SourcePath = _sourceDirectory, SourcePath = _sourceDirectory,
DestinationPath = _destinationDirectory, DestinationPath = _destinationDirectory,

View file

@ -14,7 +14,7 @@ namespace MaddoShared.Tests
[TestClass] [TestClass]
public class ImageCreatorSharpTests public class ImageCreatorSharpTests
{ {
private ImageCreatorSharp CreateService(Action<PicSettings> customize = null) private ImageCreatorGDI CreateService(Action<PicSettings> customize = null)
{ {
var settings = new PicSettings var settings = new PicSettings
{ {
@ -37,8 +37,8 @@ namespace MaddoShared.Tests
customize?.Invoke(settings); customize?.Invoke(settings);
var logger = new Mock<ILogger<ImageCreatorSharp>>().Object; var logger = new Mock<ILogger<ImageCreatorGDI>>().Object;
return new ImageCreatorSharp(settings, logger); return new ImageCreatorGDI(settings, logger);
} }
[TestMethod] [TestMethod]

View file

@ -15,8 +15,8 @@ using Microsoft.Extensions.Logging;
namespace MaddoShared namespace MaddoShared
{ {
[SuppressMessage("Interoperability", "CA1416:Validate platform compatibility")] [SuppressMessage("Interoperability", "CA1416:Validate platform compatibility")]
public class ImageCreationStuff( public class ImageCreationService(
ILogger<ImageCreationStuff> logger, ILogger<ImageCreationService> logger,
PicSettings picSettings, PicSettings picSettings,
IImageCreator imageCreatorService) IImageCreator imageCreatorService)
{ {

View file

@ -23,12 +23,12 @@ namespace MaddoShared;
/// provide a safe and testable replacement. Additional features (text/logo drawing) /// provide a safe and testable replacement. Additional features (text/logo drawing)
/// can be added later using ImageSharp.Drawing.Common and SixLabors.Fonts. /// can be added later using ImageSharp.Drawing.Common and SixLabors.Fonts.
/// </summary> /// </summary>
public class ImageCreatorAlternate : IImageCreator public class ImageCreatorImageSharp : IImageCreator
{ {
private readonly PicSettings _picSettings; private readonly PicSettings _picSettings;
private readonly ILogger<ImageCreatorAlternate> _logger; private readonly ILogger<ImageCreatorImageSharp> _logger;
public ImageCreatorAlternate(PicSettings picSettings, ILogger<ImageCreatorAlternate> logger) public ImageCreatorImageSharp(PicSettings picSettings, ILogger<ImageCreatorImageSharp> logger)
{ {
_picSettings = picSettings ?? throw new ArgumentNullException(nameof(picSettings)); _picSettings = picSettings ?? throw new ArgumentNullException(nameof(picSettings));
_logger = logger; _logger = logger;

View file

@ -27,8 +27,8 @@ public class ImageCreatorMapper : IImageCreator
_logger?.LogDebug("Resolving IImageCreator for provider '{Provider}'", provider); _logger?.LogDebug("Resolving IImageCreator for provider '{Provider}'", provider);
return provider.Equals("ALTERNATE", StringComparison.OrdinalIgnoreCase) return provider.Equals("ALTERNATE", StringComparison.OrdinalIgnoreCase)
? ResolveAndCall<ImageCreatorAlternate>(imgState, logo) ? ResolveAndCall<ImageCreatorImageSharp>(imgState, logo)
: ResolveAndCall<ImageCreatorSharp>(imgState, logo); : ResolveAndCall<ImageCreatorGDI>(imgState, logo);
} }
private Task ResolveAndCall<T>(ImageState imgState, System.Drawing.Image logo) where T : IImageCreator private Task ResolveAndCall<T>(ImageState imgState, System.Drawing.Image logo) where T : IImageCreator
@ -37,8 +37,8 @@ public class ImageCreatorMapper : IImageCreator
var impl = (IImageCreator)_sp.GetService(typeof(T)); var impl = (IImageCreator)_sp.GetService(typeof(T));
if (impl is null) if (impl is null)
{ {
_logger?.LogWarning("Requested image creator {Type} is not registered. Falling back to ImageCreatorSharp.", typeof(T).Name); _logger?.LogWarning("Requested image creator {Type} is not registered. Falling back to ImageCreatorGDI.", typeof(T).Name);
impl = (IImageCreator)_sp.GetService(typeof(ImageCreatorSharp)); impl = (IImageCreator)_sp.GetService(typeof(ImageCreatorGDI));
} }
if (impl is null) if (impl is null)

View file

@ -15,7 +15,7 @@ using SixLabors.ImageSharp.Metadata.Profiles.Exif;
namespace MaddoShared; namespace MaddoShared;
[SuppressMessage("Interoperability", "CA1416:Validate platform compatibility")] [SuppressMessage("Interoperability", "CA1416:Validate platform compatibility")]
public class ImageCreatorSharp(PicSettings picSettings, ILogger<ImageCreatorSharp> logger) : IImageCreator public class ImageCreatorGDI(PicSettings picSettings, ILogger<ImageCreatorGDI> logger) : IImageCreator
{ {
public async Task CreateImageAsync(ImageState imgState, Image logo) public async Task CreateImageAsync(ImageState imgState, Image logo)
{ {

View file

@ -37,7 +37,7 @@ namespace ImageCatalog_2
private readonly ITestService _service; private readonly ITestService _service;
private readonly ILogger<DataModel> _logger; private readonly ILogger<DataModel> _logger;
private readonly ISettingsService _settingsService; private readonly ISettingsService _settingsService;
private readonly ImageCreationStuff _imageCreationService; private readonly ImageCreationService _imageCreationService;
private readonly PicSettings _picSettings; private readonly PicSettings _picSettings;
private readonly IMapper _mapper; private readonly IMapper _mapper;
@ -47,7 +47,7 @@ namespace ImageCatalog_2
public List<string> HorizontalAlignments { get; } = new() { "Sinistra", "Centro", "Destra" }; public List<string> HorizontalAlignments { get; } = new() { "Sinistra", "Centro", "Destra" };
public DataModel(ITestService testService, ISettingsService settingsService, public DataModel(ITestService testService, ISettingsService settingsService,
ImageCreationStuff imageCreationService, PicSettings picSettings, ImageCreationService imageCreationService, PicSettings picSettings,
IMapper mapper, ILogger<DataModel> logger, MaddoShared.IVersionProvider? versionProvider = null) IMapper mapper, ILogger<DataModel> logger, MaddoShared.IVersionProvider? versionProvider = null)
{ {
_service = testService; _service = testService;
@ -1273,7 +1273,7 @@ namespace ImageCatalog_2
// Best-effort; do not fail processing on mapping issues // Best-effort; do not fail processing on mapping issues
} }
var imageCreationOptions = new ImageCreationStuff.Options var imageCreationOptions = new ImageCreationService.Options
{ {
AggiornaSottodirectory = UpdateSubdirectories, AggiornaSottodirectory = UpdateSubdirectories,
CreaSottocartelle = CreateSubfolders, CreaSottocartelle = CreateSubfolders,

View file

@ -33,7 +33,7 @@ public partial class MainForm
private bool _suppressRadioUpdates = false; private bool _suppressRadioUpdates = false;
private bool _transparentDialogOpen = false; private bool _transparentDialogOpen = false;
public MainForm(DataModel model, ImageCreationStuff imageCreationStuff, PicSettings picSettings, public MainForm(DataModel model, ImageCreationService imageCreationStuff, PicSettings picSettings,
ParametriSetup parametriSetup, ILogger<MainForm> logger) ParametriSetup parametriSetup, ILogger<MainForm> logger)
{ {
Model = model; Model = model;

View file

@ -113,7 +113,7 @@ static class Program
// Resolve optional version provider and pass to DataModel // Resolve optional version provider and pass to DataModel
var testService = sp.GetRequiredService<ITestService>(); var testService = sp.GetRequiredService<ITestService>();
var settingsService = sp.GetRequiredService<ISettingsService>(); var settingsService = sp.GetRequiredService<ISettingsService>();
var imageCreation = sp.GetRequiredService<ImageCreationStuff>(); var imageCreation = sp.GetRequiredService<ImageCreationService>();
var picSettings = sp.GetRequiredService<PicSettings>(); var picSettings = sp.GetRequiredService<PicSettings>();
var mapper = sp.GetRequiredService<IMapper>(); var mapper = sp.GetRequiredService<IMapper>();
var logger = sp.GetRequiredService<ILogger<DataModel>>(); var logger = sp.GetRequiredService<ILogger<DataModel>>();
@ -122,9 +122,9 @@ static class Program
return new DataModel(testService, settingsService, imageCreation, picSettings, mapper, logger, versionProvider); return new DataModel(testService, settingsService, imageCreation, picSettings, mapper, logger, versionProvider);
}); });
services.AddTransient<ImageCreationStuff>(); services.AddTransient<ImageCreationService>();
services.AddTransient<ImageCreatorSharp>(); services.AddTransient<ImageCreatorGDI>();
services.AddTransient<ImageCreatorAlternate>(); services.AddTransient<ImageCreatorImageSharp>();
services.AddTransient<ImageCreatorMapper>(); services.AddTransient<ImageCreatorMapper>();
// Register IImageCreator to be resolved via ImageCreatorMapper which selects concrete implementation at call time // Register IImageCreator to be resolved via ImageCreatorMapper which selects concrete implementation at call time