コード例 #1
0
        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());
        }
コード例 #2
0
        public int Value()
        {
            var lenHex = new BytesCount(_berLen).Is(1)
                                      ? (IBinary) new ShortLen(_berLen)
                                      : new LongLen(_berLen);

            return(new Hex(lenHex)
                   .ToInt());
        }
コード例 #3
0
ファイル: ValView.cs プロジェクト: tdav/MRTD.NET
 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);
     }
 }
コード例 #4
0
ファイル: Val.cs プロジェクト: tdav/MRTD.NET
        public byte[] Bytes()
        {
            var tagAndLenBytesCount = new BytesCount(
                new CombinedBinaries(
                    _tag,
                    _len
                    )
                ).Value();

            return(_berTlv
                   .Bytes()
                   .Skip(tagAndLenBytesCount)
                   .Take(new ValLength(_len).Value())
                   .ToArray());
        }