Exemple #1
0
        private static void fmtCache(
            object[,] fmtObjArr
            )
        {
            int rows = fmtObjArr.GetLength(0);
            int cols = fmtObjArr.GetLength(1);

            lock (fmtLock)
            {
                // crc and cache a scan of the format row
                fmtStringBuilder.Clear();
                for (int col = 0; col < cols; col++)
                {
                    fmtStringBuilder.Append((string)(fmtObjArr[0, col]));
                }

                var crc = Crc32.Compute(Encoding.ASCII.GetBytes(fmtStringBuilder.ToString()));
                if (fmtCRC != crc)
                {
                    // reparse the format row as it has changed
                    fmtCRC = crc;
                    if (fmtArr.Length != cols)
                    {
                        fmtArr = FmtItem.CreateItemArr(cols);
                    }

                    fmtParser.SetCols(cols);
                    fmtParser.SetStateArr(fmtArr);
                    fmtExtractor.SetStateArr(fmtArr);

                    for (int col = 0; col < cols; col++)
                    {
                        var    fmtStr     = (string)(fmtObjArr[0, col]);
                        char[] fmtCharArr = fmtStr.ToCharArray();
                        Array.Reverse(fmtCharArr); // make operators postfix and numbers least-significant-first
                        fmtParser.Parse(fmtCharArr);
                    }
                }
            }
        }