/// <summary> /// Initializes a new instance of the <see cref="ImageSharpMiddleware"/> class. /// </summary> /// <param name="next">The next middleware in the pipeline.</param> /// <param name="options">The middleware configuration options.</param> /// <param name="loggerFactory">An <see cref="ILoggerFactory"/> instance used to create loggers.</param> /// <param name="memoryAllocator">An <see cref="MemoryAllocator"/> instance used to allocate arrays transporting encoded image data.</param> /// <param name="requestParser">An <see cref="IRequestParser"/> instance used to parse image requests for commands.</param> /// <param name="resolvers">A collection of <see cref="IImageProvider"/> instances used to resolve images.</param> /// <param name="processors">A collection of <see cref="IImageWebProcessor"/> instances used to process images.</param> /// <param name="cache">An <see cref="IImageCache"/> instance used for caching images.</param> /// <param name="cacheHash">An <see cref="ICacheHash"/>instance used for calculating cached file names.</param> /// <param name="formatUtilities">Contains various format helper methods based on the current configuration.</param> public ImageSharpMiddleware( RequestDelegate next, IOptions <ImageSharpMiddlewareOptions> options, ILoggerFactory loggerFactory, MemoryAllocator memoryAllocator, IRequestParser requestParser, IEnumerable <IImageProvider> resolvers, IEnumerable <IImageWebProcessor> processors, IImageCache cache, ICacheHash cacheHash, FormatUtilities formatUtilities) { Guard.NotNull(next, nameof(next)); Guard.NotNull(options, nameof(options)); Guard.NotNull(loggerFactory, nameof(loggerFactory)); Guard.NotNull(memoryAllocator, nameof(memoryAllocator)); Guard.NotNull(requestParser, nameof(requestParser)); Guard.NotNull(resolvers, nameof(resolvers)); Guard.NotNull(processors, nameof(processors)); Guard.NotNull(cache, nameof(cache)); Guard.NotNull(cacheHash, nameof(cacheHash)); Guard.NotNull(AsyncLock, nameof(AsyncLock)); this.next = next; this.options = options.Value; this.memoryAllocator = memoryAllocator; this.requestParser = requestParser; this.resolvers = resolvers; this.processors = processors; this.cache = cache; this.cacheHash = cacheHash; var commands = new List <string>(); foreach (IImageWebProcessor processor in this.processors) { commands.AddRange(processor.Commands); } this.knownCommands = commands; this.logger = loggerFactory.CreateLogger <ImageSharpMiddleware>(); this.formatUtilities = formatUtilities; }
/// <summary> /// Initializes a new instance of the <see cref="ImageSharpMiddleware"/> class. /// </summary> /// <param name="next">The next middleware in the pipeline</param> /// <param name="options">The middleware configuration options</param> /// <param name="loggerFactory">An <see cref="ILoggerFactory"/> instance used to create loggers</param> /// <param name="bufferManager">An <see cref="IBufferManager"/> instance used to allocate arrays transporting encoded image data</param> /// <param name="requestParser">An <see cref="IRequestParser"/> instance used to parse image requests for commands</param> /// <param name="resolvers">A collection of <see cref="IImageResolver"/> instances used to resolve images</param> /// <param name="processors">A collection of <see cref="IImageWebProcessor"/> instances used to process images</param> /// <param name="cache">An <see cref="IImageCache"/> instance used for caching images</param> /// <param name="cacheHash">An <see cref="ICacheHash"/>instance used for calculating cached file names</param> /// <param name="asyncKeyLock">An <see cref="IAsyncKeyLock"/> instance used for providing locking during processing</param> public ImageSharpMiddleware( RequestDelegate next, IOptions <ImageSharpMiddlewareOptions> options, ILoggerFactory loggerFactory, IBufferManager bufferManager, IRequestParser requestParser, IEnumerable <IImageResolver> resolvers, IEnumerable <IImageWebProcessor> processors, IImageCache cache, ICacheHash cacheHash, IAsyncKeyLock asyncKeyLock) { Guard.NotNull(next, nameof(next)); Guard.NotNull(options, nameof(options)); Guard.NotNull(loggerFactory, nameof(loggerFactory)); Guard.NotNull(bufferManager, nameof(bufferManager)); Guard.NotNull(requestParser, nameof(requestParser)); Guard.NotNull(resolvers, nameof(resolvers)); Guard.NotNull(processors, nameof(processors)); Guard.NotNull(cache, nameof(cache)); Guard.NotNull(cache, nameof(cacheHash)); Guard.NotNull(asyncKeyLock, nameof(asyncKeyLock)); this.next = next; this.options = options.Value; this.bufferManager = bufferManager; this.requestParser = requestParser; this.resolvers = resolvers; this.processors = processors; this.cache = cache; this.cacheHash = cacheHash; this.asyncKeyLock = asyncKeyLock; var commands = new List <string>(); foreach (IImageWebProcessor processor in this.processors) { commands.AddRange(processor.Commands); } this.knownCommands = commands; this.logger = loggerFactory.CreateLogger <ImageSharpMiddleware>(); }