Exemplo n.º 1
0
        internal IdentificationCard(Version version, Country country, string input, List <string> subfileRecords)
        {
            // D.12.3 Header
            IssuerIdentificationNumber = (IssuerIdentificationNumber)Convert.ToInt32(input.Substring(9, 6));
            AamvaVersionNumber         = version;

            // The country is needed before we parse the subfile records so that dates can be interpreted correctly
#if NET20
            Country = country == Country.Unknown ? IdParser.GetCountry(IssuerIdentificationNumber) : country;
#else
            Country = country == Country.Unknown ? IssuerIdentificationNumber.GetCountry() : country;
#endif

            if (version == Version.Aamva2000)
            {
                JurisdictionVersionNumber = 0;
            }
            else
            {
                JurisdictionVersionNumber = Convert.ToByte(input.Substring(17, 2));
            }

            // Default Values
            WeightRange = WeightRange.None;
            AdditionalJurisdictionElements = new Dictionary <string, string>();
            ComplianceType = ComplianceType.None;

            // Data Elements
            foreach (var record in subfileRecords)
            {
                ParseRecord(record);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Parses the country based on the DCG subfile record.
        /// Gets the country from the IIN if no matching subfile record was found.
        /// </summary>
        private static Country ParseCountry(IssuerIdentificationNumber iin, Version version, List <string> subfileRecords)
        {
            // Country is not a subfile record in the AAMVA 2000 standard
            if (version == Version.Aamva2000)
            {
                return(Country.Usa);
            }

            foreach (var subfileRecord in subfileRecords)
            {
                var elementId = subfileRecord.Substring(0, 3);
                var data      = subfileRecord.Substring(3).Trim();

                if (elementId == "DCG")
                {
                    if (data == "USA")
                    {
                        return(Country.Usa);
                    }
                    if (data == "CAN" || data == "CDN")
                    {
                        return(Country.Canada);
                    }
                }
            }

            return(iin.GetCountry());
        }