public static IMiddlewareBuilder <CFTFileContext> UseExport( this IMiddlewareBuilder <CFTFileContext> app, Action <ExportFileOptions> configOption) { var options = new ExportFileOptions(); configOption(options); app.UseMiddleware <ExportFileMiddleWare, CFTFileContext>(options); return(app); }
public ExportFileMiddleWare( MiddlewareDelegate <CFTFileContext> next, ILogger <ExportFileMiddleWare> logger, IFileProviderFactory fileProviderFactory, ExportFileOptions options) : base(next, logger) { try { options.ValidationParams(); _fileProvider = fileProviderFactory.GetFileProvider(options.FileProviderType, options.FileProviderSettings); var exportFolder = _fileProvider.GetDirectoryContents(options.Path); if (!exportFolder.Exists) { throw new ArgumentException($"Каталог '{options.Path}' не существует.", nameof(options.Path)); } } catch (Exception e) { throw new CFTConfigurationException("Ошибка при конфигурации модуля экспорта файла.", e); } _option = options; }