Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
 public static QRDE Create(EMVQRTagMeta tagMeta, QRDE parent = null)
 {
     return(Create(tagMeta, "", parent));
 }