예제 #1
0
        /// <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);
        }
예제 #2
0
파일: Code11.cs 프로젝트: noikiy/Barcodes
        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;
        }
예제 #3
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);
        }
예제 #4
0
파일: UPCE.cs 프로젝트: newlysoft/Barcodes
        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;
                }
            }
        }
예제 #5
0
파일: EAN.cs 프로젝트: noikiy/Barcodes
		/// <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);
		}
예제 #6
0
파일: UPCE.cs 프로젝트: noikiy/Barcodes
        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;
            }
        }