コード例 #1
0
ファイル: CsvChecker.cs プロジェクト: jackrole/dn-repo
 public void Concat(CheckResult newResult)
 {
     this._Concat(this.WarningList, newResult.WarningList);
     this._Concat(this.ErrorList, newResult.ErrorList);
 }
コード例 #2
0
ファイル: CsvChecker.cs プロジェクト: jackrole/dn-repo
        // check with pattern that specified in parameter.
        public CheckResult Valid(List <string[]> matrix, Dictionary <int, CellChecker> cellCheckerDictionary, RowChecker rowPrevChecker, RowChecker rowPostChecker, MatrixChecker matrixPrevChecker, MatrixChecker matrixPostChecker)
        {
            CheckResult result = new CheckResult();

            string[] errors;
            string[] warnings;

            result.Content = matrix;

            #region Previous Matrix Check
            if (matrixPrevChecker != null)
            {
                matrixPrevChecker.Valid(matrix, out errors, out warnings);

                if (warnings.Length > 0)
                {
                    result.AppendCsvWarning(warnings);
                }

                if (errors.Length > 0)
                {
                    result.AppendCsvError(errors);
                    if (!this.ContinueOnError)
                    {
                        return(result);
                    }
                }
            }
            #endregion

            for (int row = 0; row < matrix.Count; row++)
            {
                #region Previous Row Check
                if (rowPrevChecker != null)
                {
                    rowPrevChecker.Valid(matrix[row], out errors, out warnings);

                    if (warnings.Length > 0)
                    {
                        result.AppendRowWarning(row, warnings);
                    }

                    if (errors.Length > 0)
                    {
                        result.AppendRowError(row, errors);
                        if (!this.ContinueOnError)
                        {
                            break;
                        }
                    }
                }
                #endregion

                #region Check Cells
                for (int col = 0; col < (cellCheckerDictionary != null ? matrix[row].Length : -1); col++)
                {
                    if (!cellCheckerDictionary.ContainsKey(col))
                    {
                        continue;
                    }

                    cellCheckerDictionary[col].Valid(matrix[row][col], out errors, out warnings);

                    if (warnings.Length > 0)
                    {
                        result.AppendCellWarning(row, col, warnings);
                    }

                    if (errors.Length > 0)
                    {
                        result.AppendCellError(row, col, errors);
                        if (!this.ContinueOnError)
                        {
                            break;
                        }
                    }
                }
                #endregion

                #region Post Row Check
                if (rowPostChecker != null)
                {
                    if (rowPostChecker.Valid(matrix[row], out errors, out warnings))
                    {
                        if (warnings.Length > 0)
                        {
                            result.AppendRowWarning(row, warnings);
                        }
                    }
                    else
                    {
                        Debug.Assert(errors.Length > 0, "No error message returned while check result is false.");
                        result.AppendRowError(row, errors);
                        if (!this.ContinueOnError)
                        {
                            break;
                        }
                    }
                }
                #endregion
            }

            #region Post Matrix Check
            if (matrixPostChecker != null)
            {
                matrixPostChecker.Valid(matrix, out errors, out warnings);

                if (warnings.Length > 0)
                {
                    result.AppendCsvWarning(warnings);
                }

                if (errors.Length > 0)
                {
                    result.AppendCsvError(errors);
                    if (!this.ContinueOnError)
                    {
                        return(result);
                    }
                }
            }
            #endregion

            return(result);
        }
コード例 #3
0
ファイル: CsvChecker.cs プロジェクト: jackrole/dn-repo
 public Viewer(CheckResult result)
 {
     _result = new List <CheckResult>();
     _result.Add(result);
 }