void.cat/VoidCat/Services/Paywall/PaywallFactory.cs

23 lines
657 B
C#
Raw Normal View History

2022-02-21 12:54:57 +00:00
using VoidCat.Model.Paywall;
using VoidCat.Services.Abstractions;
namespace VoidCat.Services.Paywall;
public class PaywallFactory : IPaywallFactory
{
private readonly IServiceProvider _services;
public PaywallFactory(IServiceProvider services)
{
_services = services;
}
2022-06-13 13:35:26 +00:00
public ValueTask<IPaywallProvider> CreateProvider(PaymentServices svc)
2022-02-21 12:54:57 +00:00
{
return ValueTask.FromResult<IPaywallProvider>(svc switch
{
2022-06-13 13:35:26 +00:00
PaymentServices.Strike => _services.GetRequiredService<StrikePaywallProvider>(),
2022-02-21 12:54:57 +00:00
_ => throw new ArgumentException("Must have a paywall config", nameof(svc))
});
}
}