public static QRDE Create(EMVQRTagMeta tagMeta, string value, QRDE parent = null) { if (!tagMeta.DataFormatter.Validate(Formatting.ASCIIStringToByteArray(value))) { throw new Exception("Invalid data value for tag:" + tagMeta.Name); } QRDE qde = new QRDE() { Tag = tagMeta.Tag, Length = value.Length, Value = value }; qde.IsTemplate = QRMetaDataSourceSingleton.Instance.DataSource.IsTemplate(qde.Tag, qde.TagParent); if (parent != null) { if (!parent.IsTemplate) { throw new Exception("Cannot add child to non template QDE"); } qde.TagParent = parent.Tag; parent.Children.AddToList(qde); } else { qde.TagParent = TagId.None; } return(qde); }
public static QRDE Create(string rawTLV, ref int pos) { QRDE tlv = new QRDE(); pos = tlv.Deserialize(rawTLV, pos); return(tlv); }
public override int Deserialize(string rawTlv, int pos) { if (rawTlv.Length == 0) { return(0); } children = new QRDEList(); Tag = (TagId)GetEnum(typeof(TagId), Convert.ToInt16(rawTlv.Substring(pos, 2))); pos = pos + 2; Length = Convert.ToInt16(rawTlv.Substring(pos, 2)); pos = pos + 2; Value = rawTlv.Substring(pos, Length); pos = pos + Length; IsTemplate = QRMetaDataSourceSingleton.Instance.DataSource.IsTemplate(Tag, TagParent); //DataFormatterBase formatter = QRMetaDataSourceSingleton.Instance.DataSource.GetFormatter(Tag, TagParent); if (IsTemplate) { for (int i = 0; i < Value.Length;) { QRDE child = new QRDE { TagParent = Tag }; i = child.Deserialize(Value, i); Children.AddToList(child); } } return(pos); }
public void Deserialize(string rawTLV) { for (int i = 0; i < rawTLV.Length;) { AddToList(QRDE.Create(rawTLV, ref i)); } }
public virtual void AddToList(QRDE tlv) { List <QRDE> result = listToManage.Where(x => x.Tag == tlv.Tag).ToList(); if (result.Count != 0) { QRDE tlvFound = result[0]; tlvFound.Value = tlv.Value; } else { listToManage.Add(tlv); } }
public static QRDE Create(EMVQRTagMeta tagMeta, QRDE parent = null) { return(Create(tagMeta, "", parent)); }