コード例 #1
0
ファイル: TLVList.cs プロジェクト: wangganggithub/dcemv
        private static TLVList DeserList(List <TLVXML> serXML)
        {
            TLVList result = new TLVList();

            serXML.ForEach((x) =>
            {
                TLV tlvToAdd = TLV.Create(x.Tag);
                result.AddToList(tlvToAdd);
                if (x.Children.Count > 0)
                {
                    tlvToAdd.Children.AddListToList(DeserList(x.Children));
                }
                else
                if (x.Value != null)
                {
                    tlvToAdd.Value = x.Value;
                }
            });
            return(result);
        }
コード例 #2
0
ファイル: TLVList.cs プロジェクト: wangganggithub/dcemv
        public bool IsEmpty(string tag)
        {
            TLV result = Get(tag);

            if (result == null)
            {
                return(false);
            }
            else
            {
                if (result.Value.Length == 0)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
        }
コード例 #3
0
ファイル: TLVasJSON.cs プロジェクト: wangganggithub/dcemv
        public static TLVasJSON Convert(TLV tlv)
        {
            TLVasJSON json = new TLVasJSON()
            {
                Tag  = tlv.Tag.TagLable,
                Name = TLVMetaDataSourceSingleton.Instance.DataSource.GetName(tlv.Tag.TagLable),
            };

            if (tlv.Tag.IsConstructed)
            {
                foreach (TLV tlvChild in tlv.Children)
                {
                    json.Children.Add(Convert(tlvChild));
                }
            }
            else
            {
                json.Value = FormattingUtils.Formatting.ByteArrayToHexString(tlv.Value);
            }
            return(json);
        }
コード例 #4
0
ファイル: TLV.cs プロジェクト: wangganggithub/dcemv
        public override int Deserialize(byte[] rawTlv, int pos)
        {
            if (rawTlv.Length == 0)
            {
                return(0);
            }

            children = new TLVList();

            //some byte streams may have FF padding between tags ??
            while (rawTlv[pos] == 0xFF)
            {
                pos++;
            }

            Tag = new T();
            pos = Tag.Deserialize(rawTlv, pos);
            Val = new V(TLVMetaDataSourceSingleton.Instance.DataSource.GetFormatter(Tag.TagLable));
            pos = Val.Deserialize(rawTlv, pos);

            if (Tag.IsConstructed)
            {
                for (int i = 0; i < Value.Length;)
                {
                    TLV child = new TLV();
                    i = child.Deserialize(Value, i);
                    //TODO: Dont like this...had to change AddToList to allow duplicates, previously if a item in the list already existed its
                    //value was replaced, some cards may return blocks of 0x00 bytes
                    //in their read record byte streams, this is not valid TLV but we have to cater for it
                    //the TLV class sees a tag of 00 with length of 00 and so on, we add the 00 tags and allow duplicates so that when things
                    //like static data for authentication is calcaulted the dups are serialized back into the origional
                    //blocks of 0x00, since the card has included this invalid data in its signature!!
                    //this should change, probably include the 0x00 blocks as some sort of custom padding tag, and switch dups back off?
                    Children.AddToList(child, true);
                }
            }
            return(pos);
        }
コード例 #5
0
ファイル: TLVasJSON.cs プロジェクト: wangganggithub/dcemv
 public static string ToJSON(TLV tlv)
 {
     return(JsonConvert.SerializeObject(Convert(tlv)));
 }
コード例 #6
0
ファイル: TLVList.cs プロジェクト: wangganggithub/dcemv
 public void AddToListIncludeDuplicates(TLV tlv)
 {
     listToManage.Add(tlv);
 }