Search code examples
abp-framework

Is there a replacement for aspnetboilerplate IIocResolver.ResolveAll?


Is there a comparible interface / functionality in abp.io ?

I need something like this:

public PaymentGatewayStore(IIocResolver iocResolver)
{
    _iocResolver = iocResolver;
}

public List<PaymentGatewayModel> GetActiveGateways()
{
    var gateways = _iocResolver.ResolveAll<IPaymentGatewayConfiguration>();

    return gateways.Where(gateway => gateway.IsActive).Select(gateway => new PaymentGatewayModel
    {
        GatewayType = gateway.GatewayType,
        SupportsRecurringPayments = gateway.SupportsRecurringPayments
    }).ToList();
}

Geert Veenstra


Solution

  • You can inject IEnumerable<IYourService> to inject all implementations of an interface. Alternatively, you can use IServiceProvider.GetServices<IYourService>(). This is standard Dependency Injection system of the AspNet Core. See the documentation.