Exemple #1
0
        private static bool TryAlphaNumericOnly(string data, Level correctionLevel, int version, out IEnumerable <EncodingSequence> sequences)
        {
            sequences = new List <EncodingSequence>();

            if (data.Length == 0)
            {
                return(false);
            }

            Logger.WriteLog($"TryAlphaNumericOnly");

            EncodingSequence seq = new EncodingSequence(correctionLevel, version)
            {
                Start = 0,
                Enc   = EncodingMode.AlphaNumeric
            };

            var result = new List <EncodingSequence> {
                seq
            };

            for (int i = 0; i < data.Length; i++)
            {
                char c = data[i];
                if (!CheckAlphaNumeric(c))
                {
                    return(false);
                }

                seq.AppendData(c);
            }

            sequences = result;
            return(true);
        }
Exemple #2
0
        private static IEnumerable <EncodingSequence> BytesOnly(string data, Level correctionLevel, int version)
        {
            if (data.Length == 0)
            {
                return(Enumerable.Empty <EncodingSequence>());
            }

            Logger.WriteLog($"BytesOnly");

            EncodingSequence seq = new EncodingSequence(correctionLevel, version)
            {
                Start = 0,
                Enc   = EncodingMode.Bytes
            };

            var result = new List <EncodingSequence> {
                seq
            };

            for (int i = 0; i < data.Length; i++)
            {
                seq.AppendData(data[i]);
            }

            return(result);
        }
Exemple #3
0
        private static EncodingSequence AddToSequences(List <EncodingSequence> result, char c, int index, EncodingMode enc, EncodingSequence last,
                                                       Level correctionLevel, int version)
        {
            if (last == null || last.Enc != enc)
            {
                last = new EncodingSequence(correctionLevel, version)
                {
                    Start = index,
                    Enc   = enc
                };

                last.AppendData(c);
                result.Add(last);
            }
            else
            if (last.Enc == enc)
            {
                last.AppendData(c);
            }

            return(last);
        }