using System.Text;

namespace QCRPG.TSL.NFC.Packets;

public static class TlvCodingForListenModeRoutingInfo
{
	public static TlvCodingForListenModeRoutingEnum ValueToTlvCodingForListenModeRouting(uint value)
	{
		switch (value)
		{
		case 0u:
			return TlvCodingForListenModeRoutingEnum.TECHNOLOGY_BASED;
		case 1u:
			return TlvCodingForListenModeRoutingEnum.PROTOCOL_BASED;
		case 2u:
			return TlvCodingForListenModeRoutingEnum.AID_BASED;
		default:
			if (value >= 3 && value <= 159)
			{
				return TlvCodingForListenModeRoutingEnum.RFU;
			}
			if (value >= 160 && value <= 255)
			{
				return TlvCodingForListenModeRoutingEnum.PROPRIETARY;
			}
			return TlvCodingForListenModeRoutingEnum.InvalidTlvCodingForListenModeRoutingValue;
		}
	}

	public static uint TlvCodingForListenModeRoutingToValue(TlvCodingForListenModeRoutingEnum enumItem)
	{
		return enumItem switch
		{
			TlvCodingForListenModeRoutingEnum.TECHNOLOGY_BASED => 0u, 
			TlvCodingForListenModeRoutingEnum.PROTOCOL_BASED => 1u, 
			TlvCodingForListenModeRoutingEnum.AID_BASED => 2u, 
			TlvCodingForListenModeRoutingEnum.RFU => 3u, 
			TlvCodingForListenModeRoutingEnum.PROPRIETARY => 160u, 
			_ => uint.MaxValue, 
		};
	}

	public static string TlvCodingForListenModeRoutingToString(TlvCodingForListenModeRoutingEnum enumItem)
	{
		return enumItem switch
		{
			TlvCodingForListenModeRoutingEnum.TECHNOLOGY_BASED => "TECHNOLOGY_BASED", 
			TlvCodingForListenModeRoutingEnum.PROTOCOL_BASED => "PROTOCOL_BASED", 
			TlvCodingForListenModeRoutingEnum.AID_BASED => "AID_BASED", 
			TlvCodingForListenModeRoutingEnum.RFU => "RFU", 
			TlvCodingForListenModeRoutingEnum.PROPRIETARY => "PROPRIETARY", 
			_ => "Invalid TlvCodingForListenModeRouting Value", 
		};
	}

	public static string TlvCodingForListenModeRoutingToDescription()
	{
		StringBuilder stringBuilder = new StringBuilder();
		stringBuilder.AppendLine("0x0 = TECHNOLOGY_BASED");
		stringBuilder.AppendLine("0x1 = PROTOCOL_BASED");
		stringBuilder.AppendLine("0x2 = AID_BASED");
		stringBuilder.AppendLine("0x3-0x9F = RFU");
		stringBuilder.AppendLine("0xA0-0xFF = PROPRIETARY");
		return stringBuilder.ToString();
	}
}
