Renamed image creators
This commit is contained in:
parent
4091fb78c5
commit
c70ab9e5de
12 changed files with 50 additions and 50 deletions
|
|
@ -22,7 +22,7 @@ public class ChunkSizeBenchmarks
|
|||
{
|
||||
private string _sourceDirectory;
|
||||
private string _destinationDirectory;
|
||||
private ImageCreationStuff _imageCreationStuff;
|
||||
private ImageCreationService _imageCreationStuff;
|
||||
private PicSettings _picSettings;
|
||||
|
||||
[Params(100)]
|
||||
|
|
@ -49,8 +49,8 @@ public class ChunkSizeBenchmarks
|
|||
builder.SetMinimumLevel(LogLevel.Warning);
|
||||
});
|
||||
|
||||
var logger = loggerFactory.CreateLogger<ImageCreationStuff>();
|
||||
var imageCreatorLogger = loggerFactory.CreateLogger<ImageCreatorSharp>();
|
||||
var logger = loggerFactory.CreateLogger<ImageCreationService>();
|
||||
var imageCreatorLogger = loggerFactory.CreateLogger<ImageCreatorGDI>();
|
||||
|
||||
_picSettings = new PicSettings
|
||||
{
|
||||
|
|
@ -75,8 +75,8 @@ public class ChunkSizeBenchmarks
|
|||
Trasparenza = 100
|
||||
};
|
||||
|
||||
var imageCreatorService = new ImageCreatorSharp(_picSettings, imageCreatorLogger);
|
||||
_imageCreationStuff = new ImageCreationStuff(logger, _picSettings, imageCreatorService);
|
||||
var imageCreatorService = new ImageCreatorGDI(_picSettings, imageCreatorLogger);
|
||||
_imageCreationStuff = new ImageCreationService(logger, _picSettings, imageCreatorService);
|
||||
}
|
||||
|
||||
[GlobalCleanup]
|
||||
|
|
@ -109,7 +109,7 @@ public class ChunkSizeBenchmarks
|
|||
[Benchmark]
|
||||
public async Task ProcessWithVariableChunkSize()
|
||||
{
|
||||
var options = new ImageCreationStuff.Options
|
||||
var options = new ImageCreationService.Options
|
||||
{
|
||||
SourcePath = _sourceDirectory,
|
||||
DestinationPath = _destinationDirectory,
|
||||
|
|
|
|||
|
|
@ -22,10 +22,10 @@ public class ImageProcessingBenchmarks
|
|||
{
|
||||
private string _sourceDirectory;
|
||||
private string _destinationDirectory;
|
||||
private ImageCreationStuff _imageCreationStuff;
|
||||
private ImageCreationService _imageCreationStuff;
|
||||
private PicSettings _picSettings;
|
||||
private ILogger<ImageCreationStuff> _logger;
|
||||
private ILogger<ImageCreatorSharp> _imageCreatorLogger;
|
||||
private ILogger<ImageCreationService> _logger;
|
||||
private ILogger<ImageCreatorGDI> _imageCreatorLogger;
|
||||
|
||||
[Params(10, 50, 100)]
|
||||
public int ImageCount { get; set; }
|
||||
|
|
@ -54,8 +54,8 @@ public class ImageProcessingBenchmarks
|
|||
builder.SetMinimumLevel(LogLevel.Warning); // Reduce noise during benchmarks
|
||||
});
|
||||
|
||||
_logger = loggerFactory.CreateLogger<ImageCreationStuff>();
|
||||
_imageCreatorLogger = loggerFactory.CreateLogger<ImageCreatorSharp>();
|
||||
_logger = loggerFactory.CreateLogger<ImageCreationService>();
|
||||
_imageCreatorLogger = loggerFactory.CreateLogger<ImageCreatorGDI>();
|
||||
|
||||
// Setup PicSettings with default values
|
||||
_picSettings = new PicSettings
|
||||
|
|
@ -81,8 +81,8 @@ public class ImageProcessingBenchmarks
|
|||
Trasparenza = 100
|
||||
};
|
||||
|
||||
var imageCreatorService = new ImageCreatorSharp(_picSettings, _imageCreatorLogger);
|
||||
_imageCreationStuff = new ImageCreationStuff(_logger, _picSettings, imageCreatorService);
|
||||
var imageCreatorService = new ImageCreatorGDI(_picSettings, _imageCreatorLogger);
|
||||
_imageCreationStuff = new ImageCreationService(_logger, _picSettings, imageCreatorService);
|
||||
}
|
||||
|
||||
[GlobalCleanup]
|
||||
|
|
@ -117,7 +117,7 @@ public class ImageProcessingBenchmarks
|
|||
[Benchmark(Description = "Process images in parallel with chunking")]
|
||||
public async Task ProcessImagesParallelWithChunks()
|
||||
{
|
||||
var options = new ImageCreationStuff.Options
|
||||
var options = new ImageCreationService.Options
|
||||
{
|
||||
SourcePath = _sourceDirectory,
|
||||
DestinationPath = _destinationDirectory,
|
||||
|
|
@ -139,7 +139,7 @@ public class ImageProcessingBenchmarks
|
|||
[Benchmark(Description = "Process images in parallel without chunking")]
|
||||
public async Task ProcessImagesParallelWithoutChunks()
|
||||
{
|
||||
var options = new ImageCreationStuff.Options
|
||||
var options = new ImageCreationService.Options
|
||||
{
|
||||
SourcePath = _sourceDirectory,
|
||||
DestinationPath = _destinationDirectory,
|
||||
|
|
@ -161,7 +161,7 @@ public class ImageProcessingBenchmarks
|
|||
[Benchmark(Description = "Process images linearly")]
|
||||
public async Task ProcessImagesLinear()
|
||||
{
|
||||
var options = new ImageCreationStuff.Options
|
||||
var options = new ImageCreationService.Options
|
||||
{
|
||||
SourcePath = _sourceDirectory,
|
||||
DestinationPath = _destinationDirectory,
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ public class ImageSizeBenchmarks
|
|||
{
|
||||
private string _sourceDirectory;
|
||||
private string _destinationDirectory;
|
||||
private ImageCreationStuff _imageCreationStuff;
|
||||
private ImageCreationService _imageCreationStuff;
|
||||
private PicSettings _picSettings;
|
||||
|
||||
[Params(50)]
|
||||
|
|
@ -58,8 +58,8 @@ public class ImageSizeBenchmarks
|
|||
builder.SetMinimumLevel(LogLevel.Warning);
|
||||
});
|
||||
|
||||
var logger = loggerFactory.CreateLogger<ImageCreationStuff>();
|
||||
var imageCreatorLogger = loggerFactory.CreateLogger<ImageCreatorSharp>();
|
||||
var logger = loggerFactory.CreateLogger<ImageCreationService>();
|
||||
var imageCreatorLogger = loggerFactory.CreateLogger<ImageCreatorGDI>();
|
||||
|
||||
_picSettings = new PicSettings
|
||||
{
|
||||
|
|
@ -84,8 +84,8 @@ public class ImageSizeBenchmarks
|
|||
Trasparenza = 100
|
||||
};
|
||||
|
||||
var imageCreatorService = new ImageCreatorSharp(_picSettings, imageCreatorLogger);
|
||||
_imageCreationStuff = new ImageCreationStuff(logger, _picSettings, imageCreatorService);
|
||||
var imageCreatorService = new ImageCreatorGDI(_picSettings, imageCreatorLogger);
|
||||
_imageCreationStuff = new ImageCreationService(logger, _picSettings, imageCreatorService);
|
||||
}
|
||||
|
||||
private static (int width, int height) GetDimensions(ImageSize size)
|
||||
|
|
@ -130,7 +130,7 @@ public class ImageSizeBenchmarks
|
|||
[Benchmark]
|
||||
public async Task ProcessDifferentImageSizes()
|
||||
{
|
||||
var options = new ImageCreationStuff.Options
|
||||
var options = new ImageCreationService.Options
|
||||
{
|
||||
SourcePath = _sourceDirectory,
|
||||
DestinationPath = _destinationDirectory,
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ public class StressTestBenchmark
|
|||
{
|
||||
private string _sourceDirectory;
|
||||
private string _destinationDirectory;
|
||||
private ImageCreationStuff _imageCreationStuff;
|
||||
private ImageCreationService _imageCreationStuff;
|
||||
private PicSettings _picSettings;
|
||||
|
||||
[Params(500, 1000)]
|
||||
|
|
@ -49,8 +49,8 @@ public class StressTestBenchmark
|
|||
builder.SetMinimumLevel(LogLevel.Warning);
|
||||
});
|
||||
|
||||
var logger = loggerFactory.CreateLogger<ImageCreationStuff>();
|
||||
var imageCreatorLogger = loggerFactory.CreateLogger<ImageCreatorSharp>();
|
||||
var logger = loggerFactory.CreateLogger<ImageCreationService>();
|
||||
var imageCreatorLogger = loggerFactory.CreateLogger<ImageCreatorGDI>();
|
||||
|
||||
_picSettings = new PicSettings
|
||||
{
|
||||
|
|
@ -75,8 +75,8 @@ public class StressTestBenchmark
|
|||
Trasparenza = 100
|
||||
};
|
||||
|
||||
var imageCreatorService = new ImageCreatorSharp(_picSettings, imageCreatorLogger);
|
||||
_imageCreationStuff = new ImageCreationStuff(logger, _picSettings, imageCreatorService);
|
||||
var imageCreatorService = new ImageCreatorGDI(_picSettings, imageCreatorLogger);
|
||||
_imageCreationStuff = new ImageCreationService(logger, _picSettings, imageCreatorService);
|
||||
|
||||
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")]
|
||||
public async Task StressTestOptimalSettings()
|
||||
{
|
||||
var options = new ImageCreationStuff.Options
|
||||
var options = new ImageCreationService.Options
|
||||
{
|
||||
SourcePath = _sourceDirectory,
|
||||
DestinationPath = _destinationDirectory,
|
||||
|
|
@ -143,7 +143,7 @@ public class StressTestBenchmark
|
|||
[Benchmark(Description = "Stress test with aggressive memory management")]
|
||||
public async Task StressTestAggressiveMemoryManagement()
|
||||
{
|
||||
var options = new ImageCreationStuff.Options
|
||||
var options = new ImageCreationService.Options
|
||||
{
|
||||
SourcePath = _sourceDirectory,
|
||||
DestinationPath = _destinationDirectory,
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ namespace MaddoShared.Tests
|
|||
[TestClass]
|
||||
public class ImageCreatorSharpTests
|
||||
{
|
||||
private ImageCreatorSharp CreateService(Action<PicSettings> customize = null)
|
||||
private ImageCreatorGDI CreateService(Action<PicSettings> customize = null)
|
||||
{
|
||||
var settings = new PicSettings
|
||||
{
|
||||
|
|
@ -37,8 +37,8 @@ namespace MaddoShared.Tests
|
|||
|
||||
customize?.Invoke(settings);
|
||||
|
||||
var logger = new Mock<ILogger<ImageCreatorSharp>>().Object;
|
||||
return new ImageCreatorSharp(settings, logger);
|
||||
var logger = new Mock<ILogger<ImageCreatorGDI>>().Object;
|
||||
return new ImageCreatorGDI(settings, logger);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
|
|
|
|||
|
|
@ -15,8 +15,8 @@ using Microsoft.Extensions.Logging;
|
|||
namespace MaddoShared
|
||||
{
|
||||
[SuppressMessage("Interoperability", "CA1416:Validate platform compatibility")]
|
||||
public class ImageCreationStuff(
|
||||
ILogger<ImageCreationStuff> logger,
|
||||
public class ImageCreationService(
|
||||
ILogger<ImageCreationService> logger,
|
||||
PicSettings picSettings,
|
||||
IImageCreator imageCreatorService)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -23,12 +23,12 @@ namespace MaddoShared;
|
|||
/// provide a safe and testable replacement. Additional features (text/logo drawing)
|
||||
/// can be added later using ImageSharp.Drawing.Common and SixLabors.Fonts.
|
||||
/// </summary>
|
||||
public class ImageCreatorAlternate : IImageCreator
|
||||
public class ImageCreatorImageSharp : IImageCreator
|
||||
{
|
||||
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));
|
||||
_logger = logger;
|
||||
|
|
|
|||
|
|
@ -27,8 +27,8 @@ public class ImageCreatorMapper : IImageCreator
|
|||
_logger?.LogDebug("Resolving IImageCreator for provider '{Provider}'", provider);
|
||||
|
||||
return provider.Equals("ALTERNATE", StringComparison.OrdinalIgnoreCase)
|
||||
? ResolveAndCall<ImageCreatorAlternate>(imgState, logo)
|
||||
: ResolveAndCall<ImageCreatorSharp>(imgState, logo);
|
||||
? ResolveAndCall<ImageCreatorImageSharp>(imgState, logo)
|
||||
: ResolveAndCall<ImageCreatorGDI>(imgState, logo);
|
||||
}
|
||||
|
||||
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));
|
||||
if (impl is null)
|
||||
{
|
||||
_logger?.LogWarning("Requested image creator {Type} is not registered. Falling back to ImageCreatorSharp.", typeof(T).Name);
|
||||
impl = (IImageCreator)_sp.GetService(typeof(ImageCreatorSharp));
|
||||
_logger?.LogWarning("Requested image creator {Type} is not registered. Falling back to ImageCreatorGDI.", typeof(T).Name);
|
||||
impl = (IImageCreator)_sp.GetService(typeof(ImageCreatorGDI));
|
||||
}
|
||||
|
||||
if (impl is null)
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ using SixLabors.ImageSharp.Metadata.Profiles.Exif;
|
|||
namespace MaddoShared;
|
||||
|
||||
[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)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ namespace ImageCatalog_2
|
|||
private readonly ITestService _service;
|
||||
private readonly ILogger<DataModel> _logger;
|
||||
private readonly ISettingsService _settingsService;
|
||||
private readonly ImageCreationStuff _imageCreationService;
|
||||
private readonly ImageCreationService _imageCreationService;
|
||||
private readonly PicSettings _picSettings;
|
||||
private readonly IMapper _mapper;
|
||||
|
||||
|
|
@ -47,7 +47,7 @@ namespace ImageCatalog_2
|
|||
public List<string> HorizontalAlignments { get; } = new() { "Sinistra", "Centro", "Destra" };
|
||||
|
||||
public DataModel(ITestService testService, ISettingsService settingsService,
|
||||
ImageCreationStuff imageCreationService, PicSettings picSettings,
|
||||
ImageCreationService imageCreationService, PicSettings picSettings,
|
||||
IMapper mapper, ILogger<DataModel> logger, MaddoShared.IVersionProvider? versionProvider = null)
|
||||
{
|
||||
_service = testService;
|
||||
|
|
@ -1273,7 +1273,7 @@ namespace ImageCatalog_2
|
|||
// Best-effort; do not fail processing on mapping issues
|
||||
}
|
||||
|
||||
var imageCreationOptions = new ImageCreationStuff.Options
|
||||
var imageCreationOptions = new ImageCreationService.Options
|
||||
{
|
||||
AggiornaSottodirectory = UpdateSubdirectories,
|
||||
CreaSottocartelle = CreateSubfolders,
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ public partial class MainForm
|
|||
private bool _suppressRadioUpdates = 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)
|
||||
{
|
||||
Model = model;
|
||||
|
|
|
|||
|
|
@ -113,7 +113,7 @@ static class Program
|
|||
// Resolve optional version provider and pass to DataModel
|
||||
var testService = sp.GetRequiredService<ITestService>();
|
||||
var settingsService = sp.GetRequiredService<ISettingsService>();
|
||||
var imageCreation = sp.GetRequiredService<ImageCreationStuff>();
|
||||
var imageCreation = sp.GetRequiredService<ImageCreationService>();
|
||||
var picSettings = sp.GetRequiredService<PicSettings>();
|
||||
var mapper = sp.GetRequiredService<IMapper>();
|
||||
var logger = sp.GetRequiredService<ILogger<DataModel>>();
|
||||
|
|
@ -122,9 +122,9 @@ static class Program
|
|||
return new DataModel(testService, settingsService, imageCreation, picSettings, mapper, logger, versionProvider);
|
||||
});
|
||||
|
||||
services.AddTransient<ImageCreationStuff>();
|
||||
services.AddTransient<ImageCreatorSharp>();
|
||||
services.AddTransient<ImageCreatorAlternate>();
|
||||
services.AddTransient<ImageCreationService>();
|
||||
services.AddTransient<ImageCreatorGDI>();
|
||||
services.AddTransient<ImageCreatorImageSharp>();
|
||||
services.AddTransient<ImageCreatorMapper>();
|
||||
|
||||
// Register IImageCreator to be resolved via ImageCreatorMapper which selects concrete implementation at call time
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue