Exemplo n.º 1
0
        /// <summary>
        /// Sets the the memory allocator configured in <see cref="Configuration.MemoryAllocator"/> of <see cref="ImageSharpMiddlewareOptions.Configuration"/>.
        /// </summary>
        /// <param name="builder">The core builder.</param>
        /// <returns>The <see cref="IImageSharpBuilder"/>.</returns>
        internal static IImageSharpBuilder SetMemoryAllocatorFromMiddlewareOptions(this IImageSharpBuilder builder)
        {
            MemoryAllocator AllocatorFactory(IServiceProvider s)
            {
                return(s.GetRequiredService <IOptions <ImageSharpMiddlewareOptions> >().Value.Configuration.MemoryAllocator);
            }

            builder.SetMemoryAllocator(AllocatorFactory);
            return(builder);
        }