public byte[] Bytes() { var berTlvBytesCount = new BytesCount(_berTlv).Value(); var berLenFormat = String.Empty; if (berTlvBytesCount < 128) { berLenFormat = String.Format("{0}", new Hex(new HexInt(berTlvBytesCount))); } else if (berTlvBytesCount > 127 && berTlvBytesCount < 256) { var bh = new BinaryHex(new BytesCount(_berTlv) .Value() .ToString("X2")); berLenFormat = String.Format("81{0}", new Hex(bh)); } else if ((berTlvBytesCount > 255 && berTlvBytesCount < 65536)) { var bh = new BinaryHex(new BytesCount(_berTlv) .Value() .ToString("X4")); berLenFormat = String.Format("82{0}", new Hex(bh)); } return(new CombinedBinaries( new Binary(new byte[] { 0x20 }), new BinaryHex(berLenFormat), _berTlv ).Bytes()); }
public int Value() { var lenHex = new BytesCount(_berLen).Is(1) ? (IBinary) new ShortLen(_berLen) : new LongLen(_berLen); return(new Hex(lenHex) .ToInt()); }
public string View() { if (_str.Length > 50) { var strLen = new BytesCount(new BinaryHex(_str)).Value(); return(String.Format("{0} ... (Hex: {1} - {2})", String.Concat(_str.Take(50)), new Hex(new HexInt(strLen)), strLen)); } else { return(_str); } }
public byte[] Bytes() { var tagAndLenBytesCount = new BytesCount( new CombinedBinaries( _tag, _len ) ).Value(); return(_berTlv .Bytes() .Skip(tagAndLenBytesCount) .Take(new ValLength(_len).Value()) .ToArray()); }