Skip to content

Add DI overloads with IServiceProvider accessible #378

@wolf8196

Description

@wolf8196

Usually methods that add a registration to DI and have some sorts of configuration options also provide overloads with IServiceProvider accessible, so that user can, for example, pull some config object from DI.
It would be nice to have something like this here as well, especially since IServiceProvider already seems accessible inside the library, but ignored.

Image

Something like this would be helpful:

public static IServiceCollection AddWebOptimizer(this IServiceCollection services, Action<IAssetPipeline> assetPipeline, Func<IServiceProvider, WebOptimizerOptions> configureWebOptimizer)
{
    return services.RegisterComponents(assetPipeline,
        ServiceDescriptor.Singleton<IConfigureOptions<WebOptimizerOptions>, InCodeWebOptimizerConfig>(sp =>
            new InCodeWebOptimizerConfig(configureWebOptimizer(sp))));
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions