Exemplo n.º 1
0
        public virtual bool Validate()
        {
            char checkDigit = '0';

            if (isn.Length == 13)
            {
                checkDigit = CheckDigitRoutines.generateCheck13digit(isn);
            }
            else if (isn.Length == 10)
            {
                checkDigit = CheckDigitRoutines.generateCheckIsbn10Issn(isn, 10);
            }
            else if (isn.Length == 8)
            {
                checkDigit = CheckDigitRoutines.generateCheckIsbn10Issn(isn, 8);
            }
            else if (isn.Length == 16)
            {
                checkDigit = CheckDigitRoutines.generateCheckIsni(isn);
            }
            else
            {
                return(false);
            }
            return(isn.EndsWith(checkDigit));
        }
Exemplo n.º 2
0
 private void checkTypes()
 {
     if (isValid && identifierType == IdentifierType.ISBN10)
     {
         isn            = $"{"978"}{isn.Substring(0, 9)}{CheckDigitRoutines.generateCheck13digit($"{"978"}{isn}")}";
         identifierType = IdentifierType.ISBN;
     }
     if (isValid && identifierType == IdentifierType.EANISSN)
     {
         isn            = $"{isn.Substring(3, 7)}{CheckDigitRoutines.generateCheckIsbn10Issn(isn.Substring(3, 7), 8)}";
         identifierType = IdentifierType.ISSN;
     }
 }