private static bool IsValid(char symbol) { if (!Code128.IsNormal(symbol)) { return(Code128.IsSpecial(symbol)); } return(true); }
protected override string GetFormat(string value) { StringBuilder stringBuilder = new StringBuilder(); for (int index = 0; index < value.Length; ++index) { char symbol = value[index]; if (Code128.IsNormal(symbol)) { stringBuilder.Append(symbol); } } return(stringBuilder.ToString()); }
protected override void ValidateValue(string value) { if (string.IsNullOrEmpty(value)) { return; } for (int index = 0; index < value.Length; ++index) { char symbol = value[index]; if (!Code128.IsValid(symbol)) { throw new InvalidSymbolException(symbol); } } }
protected override string GetEncoding(string value) { if (string.IsNullOrEmpty(value)) { return(string.Empty); } int[] indices = this.GetIndices(value); List <int> intList = new List <int>((IEnumerable <int>)indices); if (this.Checksum) { intList.Add(Code128.GetChecksum(indices)); } intList.Add(Code128.suffix); StringBuilder stringBuilder = new StringBuilder(); foreach (int index in intList) { stringBuilder.Append(Code128.encoding[index]); } stringBuilder.Append(Symbology1D.BarChar); stringBuilder.Append(Symbology1D.BarChar); return(stringBuilder.ToString()); }
protected virtual int[] GetIndices(string value) { return(Code128.GetIndices(value, 0, value.Length)); }
private static int GetChecksum(int[] array) { return(Code128.GetChecksum(array, 103)); }