示例#1
0
        /// <summary>
        /// Retreive the value of the gigen tag
        /// </summary>
        /// <param name="type">Where to look in the card data</param>
        /// <param name="tagname">The tag name</param>
        /// <returns>The tag data</returns>
        public string GetTagValue(EmvConstants.ResponceType type, string tagname)
        {
            string res = string.Empty;

            switch (type)
            {
            case EmvConstants.ResponceType.All:
                res = _GetTagValue(EmvConstants.ResponceType.ReaderRecord, tagname);
                if (string.IsNullOrEmpty(res))
                {
                    res = _GetTagValue(EmvConstants.ResponceType.Gpo, tagname);
                }
                return(res);

            case EmvConstants.ResponceType.Select:
                throw new NotImplementedException("EMV.ResponceType.Select not implemented");

            default:
                return(_GetTagValue(type, tagname));
            }
        }
示例#2
0
        /// <summary>
        /// Handles the retreival of the GetTagValue
        /// </summary>
        /// <see cref="GetTagValue(EmvConstants.ResponceType, string)"/>
        /// <param name="type"></param>
        /// <param name="tagname"></param>
        /// <returns></returns>
        private string _GetTagValue(EmvConstants.ResponceType type, string tagname)
        {
            string res = null;

            switch (type)
            {
            case EmvConstants.ResponceType.ReaderRecord:
                try
                {
                    if (EmvRecords == null)
                    {
                        return(null);
                    }
                    res = (from r in EmvRecords
                           from t in r.TLV_READRECORD.TagList
                           where t?.TagStringName.ToUpper() == tagname.ToUpper()
                           select t?.TlvData).SingleOrDefault();
                }
                catch (InvalidOperationException)
                {
                    throw new Exception($"The smartcard has many tags with name {tagname}");
                }
                break;

            case EmvConstants.ResponceType.Gpo:
                res = (from t in TLV_GPO.TagList where string.Equals(t.TagStringName, tagname, StringComparison.CurrentCultureIgnoreCase) select t.TlvData)
                      .SingleOrDefault();
                break;

            case EmvConstants.ResponceType.Select:
                throw new NotImplementedException("EMV.ResponceType.Select");

            default:
                throw new ArgumentOutOfRangeException(nameof(type), type, null);
            }

            return(res);
        }