using FileSignatures; using FileSignatures.Formats; using StopShopping.FileApi.Services.Implementions; namespace StopShopping.FileApi.Services; public static class Extensions { public static IServiceCollection AddServices(this IServiceCollection services, IConfiguration appOptions) { services.Configure(appOptions); services.AddValidation(); var imageFormats = FileFormatLocator.GetFormats().OfType(); var imageInspector = new FileFormatInspector(imageFormats); services.AddSingleton(imageInspector); services.AddScoped(); return services; } public static string GetTargetDirectory(this UploadScences uploadScences) { return uploadScences switch { UploadScences.Avatar => "avatar", UploadScences.Product => "product", UploadScences.Category => "category", _ => throw new ArgumentOutOfRangeException(nameof(uploadScences)) }; } }