/// <summary> /// Calculate parity for given list of codes /// </summary> /// <param name="codes">list of values</param> protected virtual void CalculateParity(CodedValueCollection codes) { if (Parity == null) { CreateParity(); } bool[] parity = Parity[codes[0]]; for (int i = 1; i < codes.Count; i++) { if (i < 1 + DigitGrouping[1]) { if (parity[i - 1]) { codes[i] += 10; } } else { codes[i] += 20; } } codes.RemoveAt(0); }
public override string AddChecksum(string value, CodedValueCollection codes) { codes.RemoveAt(codes.Count - 1); value = DoChecksumCalculation(value, 10, codes); if (value.Length >= 10) value = DoChecksumCalculation(value, 9,codes); codes.Add(LIMIT); return value; }
public override string AddChecksum(string value, CodedValueCollection codes) { codes.RemoveAt(codes.Count - 1); value = DoChecksumCalculation(value, 10, codes); if (value.Length >= 10) { value = DoChecksumCalculation(value, 9, codes); } codes.Add(LIMIT); return(value); }
protected override void CalculateParity(CodedValueCollection codes) { int checkdigit; if (codes.Count == 8) { checkdigit = codes[7]; codes.RemoveAt(7); } else { checkdigit = CalculateCheckCode(codes); } bool[] parity = Parity[checkdigit]; for (int i = 0; i < codes.Count; i++) { if (parity[i] == (codes[0] == 0)) { codes[i] += 10; } } }
/// <summary> /// Calculate parity for given list of codes /// </summary> /// <param name="codes">list of values</param> protected virtual void CalculateParity(CodedValueCollection codes) { bool[] parity = Parity[codes[0]]; for (int i = 1; i < codes.Count; i++) { if (i < 1 + DigitGrouping[1]) { if (parity[i - 1]) codes[i] += 10; } else codes[i] += 20; } codes.RemoveAt(0); }
protected override void CalculateParity(CodedValueCollection codes) { int checkdigit; if (codes.Count == 8) { checkdigit = codes[7]; codes.RemoveAt(7); } else { checkdigit = CalculateCheckCode(codes); } bool[] parity = Parity[checkdigit]; for (int i = 0; i < codes.Count; i++) { if (parity[i] == (codes[0] == 0)) codes[i] += 10; } }