public void CanAddRemoveAllFactoryImageProcessors() { var services = new ServiceCollection(); IImageSharpBuilder builder = services.AddImageSharp(); builder.AddProcessor(_ => new MockWebProcessor()); Assert.Single(services, IsService <IImageWebProcessor, MockWebProcessor>); Assert.Single(services, IsServiceImplementationFactory <IImageWebProcessor, MockWebProcessor>); builder.ClearProcessors(); Assert.DoesNotContain(services, IsService <IImageWebProcessor>); }
public void CanAddRemoveImageProcessors() { var services = new ServiceCollection(); IImageSharpBuilder builder = services.AddImageSharp(); builder.AddProcessor <MockWebProcessor>(); Assert.Single(services, IsService <IImageWebProcessor, MockWebProcessor>); Assert.Single(services, IsServiceImplementationType <IImageWebProcessor, MockWebProcessor>); builder.RemoveProcessor <MockWebProcessor>(); Assert.DoesNotContain(services, IsService <IImageWebProcessor, MockWebProcessor>); }
/// <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>(); }
public static IImageSharpBuilder AddAutoCropProcessor(this IImageSharpBuilder builder) { if (builder == null) { return(builder); } var index = IndexOfProcessor <ResizeWebProcessor>(builder.Services); if (index < 0) { builder.AddProcessor <AutoCropWebProcessor>(); } else { builder.Services.Insert(index, ServiceDescriptor.Singleton <IImageWebProcessor, AutoCropWebProcessor>()); } return(builder); }
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>(); }