dotnetcore/AspectCore-Framework

DynamicProxyServiceProviderFactory 能否支持ServiceProviderOptions

obpt123 opened this issue · 2 comments

大概期望的实现方式是这样的

    public class DynamicProxyServiceProviderFactory : IServiceProviderFactory<IServiceCollection>
    {
        public DynamicProxyServiceProviderFactory()
        {
        }

        public DynamicProxyServiceProviderFactory(bool validateScopes) : this(new ServiceProviderOptions
            {ValidateScopes = validateScopes})
        {
        }

        public DynamicProxyServiceProviderFactory(ServiceProviderOptions serviceProviderOptions)
        {
            ServiceProviderOptions = serviceProviderOptions;
        }

        public ServiceProviderOptions ServiceProviderOptions { get; }

        public IServiceCollection CreateBuilder(IServiceCollection services)
        {
            return services;
        }

        public IServiceProvider CreateServiceProvider(IServiceCollection containerBuilder)
        {
            return ServiceProviderOptions is null
                ? containerBuilder.BuildDynamicProxyProvider()
                : containerBuilder.BuildDynamicProxyProvider(ServiceProviderOptions);
        }
    }

可以考虑实现。

已实现