public void SetConfigureOption(ConfigureOption option) { if (option == null) { return; } _interceptors = option.Interceptors; }
public static IServiceCollection AddScopeByProxy <TInterface, TImpl>(this IServiceCollection services, Action <ConfigureOption> configureOption) where TInterface : class where TImpl : class, TInterface, new() { services.AddScoped <TImpl>(); services.TryAddScoped <ProxyDecorator>(); services.AddScoped <TInterface>(serviceProvider => { var impl = serviceProvider.GetService <TImpl>(); var tService = new ProxyDecorator().Create <TInterface>(impl); var option = new ConfigureOption(); configureOption(option); ((ProxyDecorator)tService).SetConfigureOption(option); return((TInterface)tService); }); return(services); }