Beispiel #1
0
        public static BirthNumber Create(string number)
        {
            BirthNumber result;

            try
            {
                result = new BirthNumber(number);
            }
            catch (NinException)
            {
                result = null;
            }
            return(result);
        }
Beispiel #2
0
        public static BirthNumber OneRandom(DateTime dateFrom, DateTime dateTo, GenderRequest gender = GenderRequest.Any, int maxTryCount = DefaultRetryCount)
        {
            BirthNumber result = null;

            for (int tryCounter = 0; tryCounter < maxTryCount; ++tryCounter)
            {
                string number = OneRandomNumber(dateFrom, dateTo, gender);
                result = Create(number);
                if (result != null)
                {
                    break;
                }
            }
            return(result);
        }
Beispiel #3
0
        public static BirthNumber OneRandom(int maxTryCount = DefaultRetryCount)
        {
            BirthNumber result = null;

            for (int tryCounter = 0; tryCounter < maxTryCount; ++tryCounter)
            {
                string number = OneRandomNumber();
                result = Create(number);
                if (result != null)
                {
                    break;
                }
            }
            return(result);
        }
Beispiel #4
0
        private static void AddOneIfLegal(ICollection <BirthNumber> birthNumbers, DateTime dt, int individual)
        {
            string number      = string.Format("{0:ddMMyy}{1:000}", dt, individual);
            char   checkDigit1 = Modulo11(WeightsForCheckDigit1, number);

            if ('-' != checkDigit1)
            {
                number += checkDigit1;
                char checkDigit2 = Modulo11(WeightsForCheckDigit2, number);
                if ('-' != checkDigit2)
                {
                    number += checkDigit2;
                    BirthNumber birthNumber = new BirthNumber(number);
                    birthNumbers.Add(birthNumber);
                }
            }
        }