예제 #1
0
        public string Generate(ICodeConfiguration codeConfiguration)
        {
            _codeConfiguration = codeConfiguration;
            if (!isValidConfiguration())
            {
                return(_code);
            }

            string startingfrom = _codeConfiguration.GetStartingFrom();


            if (!Regex.IsMatch(startingfrom, (_decimalpattern + "$")))
            {
                throw new Exception(_rm.GetString("AutoincrementCanNotBeApplied"));
            }

            string[] numbers = Regex.Split(startingfrom, _charpattern);

            if (numbers.Length == 0)
            {
                throw new Exception(_rm.GetString("AutoincrementCanNotBeApplied"));
            }

            string startnumber   = numbers[numbers.Length - 1];
            Int64  nextnumber    = 0;
            Int64  currentnumber = 0;

            currentnumber = int.Parse(numbers[numbers.Length - 1]);

            nextnumber = currentnumber + 1;
            _code      = startingfrom.Replace(startnumber, nextnumber.ToString().PadLeft(startnumber.Length, '0'));
            return(_code);
        }
예제 #2
0
        public string Generate(ICodeConfiguration codeConfiguration)
        {
            _codeConfiguration = codeConfiguration;
            if (!isValidConfiguration())
            {
                return(_code);
            }

            Random obj = new Random();

            int  length = _possibles.Length;
            char letter;
            int  lengthnewstring = codeConfiguration.GetLength();

            for (int i = 0; i < lengthnewstring; i++)
            {
                letter = _possibles[obj.Next(length)];
                _code += letter.ToString();
            }

            return(_code);
        }