btcpayserver/BTCPayServer/Services/PrettyNameProvider.cs
2024-04-04 16:31:04 +09:00

24 lines
702 B
C#

#nullable enable
using System.Collections.Generic;
using BTCPayServer.Payments;
namespace BTCPayServer.Services
{
public class PrettyNameProvider
{
private readonly Dictionary<PaymentMethodId, IPaymentModelExtension> _extensions;
public PrettyNameProvider(Dictionary<PaymentMethodId, IPaymentModelExtension> extensions)
{
_extensions = extensions;
}
public string PrettyName(PaymentMethodId paymentMethodId)
{
if (paymentMethodId is null)
return "<NULL>";
_extensions.TryGetValue(paymentMethodId, out var n);
return n?.DisplayName ?? paymentMethodId.ToString();
}
}
}