| | 1 | | namespace NLightning.Infrastructure.Protocol.Factories; |
| | 2 | |
|
| | 3 | | using Domain.Protocol.Interfaces; |
| | 4 | | using Domain.Protocol.Tlv; |
| | 5 | | using Tlv.Converters; |
| | 6 | |
|
| | 7 | | public class TlvConverterFactory : ITlvConverterFactory |
| | 8 | | { |
| 4 | 9 | | private readonly Dictionary<Type, ITlvConverter> _converters = new(); |
| | 10 | |
|
| 4 | 11 | | public TlvConverterFactory() |
| | 12 | | { |
| 4 | 13 | | RegisterConverters(); |
| 4 | 14 | | } |
| | 15 | |
|
| | 16 | | public ITlvConverter<TTlv>? GetConverter<TTlv>() where TTlv : BaseTlv |
| | 17 | | { |
| 128 | 18 | | return _converters.GetValueOrDefault(typeof(TTlv)) as ITlvConverter<TTlv>; |
| | 19 | | } |
| | 20 | |
|
| | 21 | | private void RegisterConverters() |
| | 22 | | { |
| 4 | 23 | | _converters.Add(typeof(BlindedPathTlv), new BlindedPathTlvConverter()); |
| 4 | 24 | | _converters.Add(typeof(ChannelTypeTlv), new ChannelTypeTlvConverter()); |
| 4 | 25 | | _converters.Add(typeof(FeeRangeTlv), new FeeRangeTlvConverter()); |
| 4 | 26 | | _converters.Add(typeof(FundingOutputContributionTlv), new FundingOutputContributionTlvConverter()); |
| 4 | 27 | | _converters.Add(typeof(NetworksTlv), new NetworksTlvConverter()); |
| 4 | 28 | | _converters.Add(typeof(NextFundingTlv), new NextFundingTlvConverter()); |
| 4 | 29 | | _converters.Add(typeof(RemoteAddressTlv), new RemoteAddressTlvConverter()); |
| 4 | 30 | | _converters.Add(typeof(RequireConfirmedInputsTlv), new RequireConfirmedInputsTlvConverter()); |
| 4 | 31 | | _converters.Add(typeof(ShortChannelIdTlv), new ShortChannelIdTlvConverter()); |
| 4 | 32 | | _converters.Add(typeof(UpfrontShutdownScriptTlv), new UpfrontShutdownScriptTlvConverter()); |
| 4 | 33 | | } |
| | 34 | | } |