public void CanSetCacheHash() { var services = new ServiceCollection(); IImageSharpBuilder builder = services.AddImageSharp(); builder.SetCacheHash <MockCacheHash>(); Assert.Single(services, IsService <ICacheHash>); Assert.Single(services, IsServiceImplementationType <ICacheHash, MockCacheHash>); builder.SetCacheHash(_ => new MockCacheHash()); Assert.Single(services, IsService <ICacheHash>); Assert.Single(services, IsServiceImplementationFactory <ICacheHash, MockCacheHash>); }
/// <summary> /// Adds the default service to the service collection. /// </summary> /// <param name="builder">The <see cref="IImageSharpBuilder"/> that can be used to further configure the ImageSharp services.</param> private static void AddDefaultServices(IImageSharpBuilder builder) { builder.SetRequestParser <QueryCollectionRequestParser>(); builder.SetCache <PhysicalFileSystemCache>(); builder.SetCacheHash <CacheHash>(); builder.AddProvider <PhysicalFileSystemProvider>(); builder.AddProcessor <ResizeWebProcessor>() .AddProcessor <FormatWebProcessor>() .AddProcessor <BackgroundColorWebProcessor>(); }
private static void AddDefaultServices( IImageSharpBuilder builder, Action <ImageSharpMiddlewareOptions> setupAction) { builder.Services.Configure(setupAction); builder.Services.AddSingleton <FormatUtilities>(); builder.Services.AddSingleton <AsyncKeyReaderWriterLock <string> >(); builder.SetRequestParser <QueryCollectionRequestParser>(); builder.SetCache <PhysicalFileSystemCache>(); builder.SetCacheKey <UriRelativeLowerInvariantCacheKey>(); builder.SetCacheHash <SHA256CacheHash>(); builder.AddProvider <PhysicalFileSystemProvider>(); builder.AddProcessor <ResizeWebProcessor>() .AddProcessor <FormatWebProcessor>() .AddProcessor <BackgroundColorWebProcessor>() .AddProcessor <QualityWebProcessor>(); builder.AddConverter <IntegralNumberConverter <sbyte> >(); builder.AddConverter <IntegralNumberConverter <byte> >(); builder.AddConverter <IntegralNumberConverter <short> >(); builder.AddConverter <IntegralNumberConverter <ushort> >(); builder.AddConverter <IntegralNumberConverter <int> >(); builder.AddConverter <IntegralNumberConverter <uint> >(); builder.AddConverter <IntegralNumberConverter <long> >(); builder.AddConverter <IntegralNumberConverter <ulong> >(); builder.AddConverter <SimpleCommandConverter <decimal> >(); builder.AddConverter <SimpleCommandConverter <float> >(); builder.AddConverter <SimpleCommandConverter <double> >(); builder.AddConverter <SimpleCommandConverter <string> >(); builder.AddConverter <SimpleCommandConverter <bool> >(); builder.AddConverter <ArrayConverter <sbyte> >(); builder.AddConverter <ArrayConverter <byte> >(); builder.AddConverter <ArrayConverter <short> >(); builder.AddConverter <ArrayConverter <ushort> >(); builder.AddConverter <ArrayConverter <int> >(); builder.AddConverter <ArrayConverter <uint> >(); builder.AddConverter <ArrayConverter <long> >(); builder.AddConverter <ArrayConverter <ulong> >(); builder.AddConverter <ArrayConverter <decimal> >(); builder.AddConverter <ArrayConverter <float> >(); builder.AddConverter <ArrayConverter <double> >(); builder.AddConverter <ArrayConverter <string> >(); builder.AddConverter <ArrayConverter <bool> >(); builder.AddConverter <ListConverter <sbyte> >(); builder.AddConverter <ListConverter <byte> >(); builder.AddConverter <ListConverter <short> >(); builder.AddConverter <ListConverter <ushort> >(); builder.AddConverter <ListConverter <int> >(); builder.AddConverter <ListConverter <uint> >(); builder.AddConverter <ListConverter <long> >(); builder.AddConverter <ListConverter <ulong> >(); builder.AddConverter <ListConverter <decimal> >(); builder.AddConverter <ListConverter <float> >(); builder.AddConverter <ListConverter <double> >(); builder.AddConverter <ListConverter <string> >(); builder.AddConverter <ListConverter <bool> >(); builder.AddConverter <ColorConverter>(); builder.AddConverter <EnumConverter>(); builder.Services.AddSingleton <CommandParser>(); }