Exemplo n.º 1
0
        public static ElementStringFormat GetFormat(string applicationIdentifier, CharType dataType, int dataLength, bool fnc1, string description)
        {
            ElementStringFormat format = new ElementStringFormat();

            format.AI = applicationIdentifier;
            format.DataType = dataType;
            format.DataLength = dataLength;
            format.FNC1 = fnc1;
            format.Description = description;
            format.NumberOfDecimal = -1;

            return format;
        }
Exemplo n.º 2
0
        /// <summary>
        /// Restituisce il successivo ElementString a partire dall'indice corrente dell'algoritmo
        /// </summary>
        /// <param name="format">Il formato dell'ElementString da parsare</param>
        /// <returns></returns>
        /// <exception cref="Drkstr.GS1AlgorithmException" /> in caso di errore
        public ElementString NextElementWithFormat(ElementStringFormat format)
        {
            ElementString element = new ElementString(format);

            try
            {
                if (format.FNC1 == true) // Lunghezza variabile
                {
                    int startIndex = Index;

                    while (Index < Barcode.Length && (Index - startIndex) <= format.DataLength)
                    {
                        if (CharIsFNC1(Barcode[Index]))
                        {
                            // Carattere di escape: il token e' pronto e si avanza l'indice di uno
                            Index++;
                            break;
                        }
                        else
                        {
                            element.Data = element.Data + Barcode[Index];
                            Index++;
                        }
                    }
                }
                else // Lunghezza fissa
                {
                    for (int i = 0; i < element.Format.DataLength; i++)
                    {
                        element.Data = element.Data + Barcode[Index];
                        Index++;
                    }
                }

                return element;
            }
            catch (IndexOutOfRangeException)
            {
                throw new GS1AlgorithmException(String.Format("Unexpected end of format (AI={0})", AI));
            }
        }
Exemplo n.º 3
0
 public ElementString(ElementStringFormat esf)
 {
     Format = esf;
     Data = "";
 }