Imageprocessor: Only one instance per service type possible

Created on 24 Oct 2016  路  3Comments  路  Source: JimBobSquarePants/ImageProcessor

If I want to set up the CloudImageService to be used with two different prefixes, it seems that ImageProcessor is not able to fetch the configuration for it.

When fetching the settings in ImageProcessorConfiguration.cs, it uses the name of the type:

2016-10-24_1354

But you can supply any name you want in the config:
2016-10-24_1357

Is this intentional, or is this a bug in the ImageProcessorConfiguration?

bug framework wontfix

Most helpful comment

I encountered the same issue.

As a workaround, you can define a new class inheriting from the service that you want to duplicate:

public class CloudImageService2 : CloudImageService {}

and reference it in your config:

<service name="CloudImageService2" type="Your.Namespace.CloudImageService2, YourAssembly">

All 3 comments

Good spot! I would say that's a bug. Services should be reusable.

I encountered the same issue.

As a workaround, you can define a new class inheriting from the service that you want to duplicate:

public class CloudImageService2 : CloudImageService {}

and reference it in your config:

<service name="CloudImageService2" type="Your.Namespace.CloudImageService2, YourAssembly">

Bad news I'm afraid...

The only way I can fix this is to change the IImageService interface which I cannot do without a major version and I doubt there will ever be a V5. (What with the excellent progress of ImageSharp and the move to netcore) so I'm going to close this as wontfix but document the workaround in the ImageProcessor docs.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

skttl picture skttl  路  5Comments

Jogai picture Jogai  路  6Comments

DocCaliban picture DocCaliban  路  4Comments

nul800sebastiaan picture nul800sebastiaan  路  7Comments

rcharb1 picture rcharb1  路  8Comments