/// <inheritdoc /> /// <example> /// <code>TLVData = new TLVData("6F 1A 84 0E 31 50 41 59 2E 53 59 53 2E 44 44 46 30 31 A5 08 88 01 02 5F 2D 02 66 72");</code> /// <para>Default format: /// <code>String.Format("{0}", tlv);</code> /// output: <c>T:6F L:1A V:( T:84 L:0E V:31 50 41 59 2E 53 59 53 2E 44 44 46 30 31 )( T:A5 L:08 V:( T:88 L:01 V:02 )( T:5F2D L:02 V:66 72 ) )</c> /// </para> /// <para>Format "T": tag only /// <code>String.Format("{0:T}", tlv);</code> /// output: <c>6F</c> /// </para> /// <para>Format "L": length only /// <code>String.Format("{0:L}", tlv);</code> /// output: <c>1A</c> /// </para> /// <para>Format "V": value only; value is interpreted as TLV if its a complex tag /// <code>String.Format("{0:V}", tlv);</code> /// output: <c>( T:84 L:0E V:31 50 41 59 2E 53 59 53 2E 44 44 46 30 31 )( T:A5 L:08 V:( T:88 L:01 V:02 )( T:5F2D L:02 V:66 72 ) )</c> /// </para> /// <para>Format "Vh": raw value, no interpretation /// <code>String.Format("{0:Vh}", tlv);</code> /// output: <c>84 0E 31 50 41 59 2E 53 59 53 2E 44 44 46 30 31 A5 08 88 01 02 5F 2D 02 66 72</c> /// </para> /// </example> public string ToString(string format, IFormatProvider formatProvider) { switch (format) { case "T": var tagFormatter = "{0:X" + 2 * LengthOfT + "}"; return(String.Format(tagFormatter, tag)); case "L": return(EncodedLength.ToHexa('\0')); case "V": if (IsConstructed()) { return(innerTlvs.Aggregate(String.Empty, (current, subField) => current + String.Format("( {0} )", subField))); } return(value.ToHexa()); case "Vh": return(Value.ToHexa()); default: return(String.Format("T:{0:T} L:{0:L} V:{0:V}", this)); } }
public override int GetHashCode() { const int k = 16777619; unchecked { int h = (int)2166136261; h = (h * k) ^ EncodedLength.GetHashCode(); h = (h * k) ^ SupportsSequence.GetHashCode(); h = (h * k) ^ AcceptableCauseOfTransmission?.Length.GetHashCode() ?? 0; return(h); } }