2024-04-04 16:31:04 +09:00
|
|
|
#nullable enable
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using BTCPayServer.Payments;
|
|
|
|
|
|
|
|
namespace BTCPayServer.Services
|
|
|
|
{
|
|
|
|
public class PrettyNameProvider
|
|
|
|
{
|
2024-10-07 19:58:08 +09:00
|
|
|
private readonly Dictionary<PaymentMethodId, ICheckoutModelExtension> _extensions;
|
2024-04-04 16:31:04 +09:00
|
|
|
|
2024-10-07 19:58:08 +09:00
|
|
|
public PrettyNameProvider(Dictionary<PaymentMethodId, ICheckoutModelExtension> extensions)
|
2024-04-04 16:31:04 +09:00
|
|
|
{
|
|
|
|
_extensions = extensions;
|
|
|
|
}
|
|
|
|
public string PrettyName(PaymentMethodId paymentMethodId)
|
|
|
|
{
|
|
|
|
if (paymentMethodId is null)
|
|
|
|
return "<NULL>";
|
|
|
|
_extensions.TryGetValue(paymentMethodId, out var n);
|
|
|
|
return n?.DisplayName ?? paymentMethodId.ToString();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|