private IRowVaildator GetValidatorInstance(ValidateStatement vs)
        {
            if (!Validators.Contains(vs.Validator))
                throw new ArgumentException(string.Format("找不到指定的 Row Validator:{0}", vs.Validator));

            return Validators[vs.Validator];
        }
        private bool IsCorrectable(IRowStream RowSource, ValidateStatement vs, IRowVaildator rv)
        {
            bool result = false;

            if (vs.AutoCorrect)
            {
                string newValue = rv.Correct(RowSource);

                XmlDocument xmldoc = new XmlDocument();

                try
                {
                    xmldoc.LoadXml(newValue);
                }
                catch
                {
                    throw new ArgumentException(string.Format("Correct Specification Invalid ({0}).", rv.ToString()));
                }

                if (xmldoc.DocumentElement.ChildNodes.Count > 0)
                {
                    foreach (XmlNode each in xmldoc.DocumentElement.ChildNodes)
                    {
                        XmlElement n = each as XmlElement;
                        if (n == null) continue;

                        string OldValue = RowSource.GetValue(n.LocalName);
                        if (AutoCorrect != null)
                        {
                            AutoCorrectEventArgs args = new AutoCorrectEventArgs(RowSource, ValidatorType.Row, n.LocalName, OldValue, n.InnerText);
                            if (AutoCorrect != null) AutoCorrect(this, args);
                            result = true; //修正成功。
                        }
                    }
                }
                else
                {
                    ErrorCapturedEventArgs args = new ErrorCapturedEventArgs(RowSource, ValidatorType.Row, vs.ErrorType, string.Empty, rv.ToString(vs.Description));
                    if (ErrorCaptured != null) ErrorCaptured(this, args);
                }
            }
            else
            {
                ErrorCapturedEventArgs args = new ErrorCapturedEventArgs(RowSource, ValidatorType.Row, vs.ErrorType, string.Empty, rv.ToString(vs.Description));
                if (ErrorCaptured != null) ErrorCaptured(this, args);
            }

            return result;
        }
        private bool IsValidatorEnabled(IRowStream RowSource, ValidateStatement vs)
        {
            //取出 When 值, 判斷是否要檢查
            bool doValidate = true;
            if (!string.IsNullOrEmpty(vs.When))
            {
                if (!Conditions.Contains(vs.When))
                    throw new ArgumentException(string.Format("找不到指定的 Condition:{0}", vs.When));

                doValidate = Conditions[vs.When].Evaluate(RowSource);
            }
            return doValidate;
        }
 private bool IsCorrectable(IRowStream row, FieldDescription field,
     string fieldValue, bool isValidated,
     ValidateStatement vs, IFieldValidator validator)
 {
     if (vs.AutoCorrect)
     {
         string newValue = validator.Correct(fieldValue);
         if (!string.IsNullOrEmpty(newValue))
         {
             XmlDocument xmldoc = new XmlDocument();
             xmldoc.LoadXml(newValue);
             newValue = xmldoc.DocumentElement.InnerText;
             if (AutoCorrect != null)
             {
                 AutoCorrectEventArgs args = new AutoCorrectEventArgs(row, ValidatorType.Field, field.Name, fieldValue, newValue);
                 if (AutoCorrect != null) AutoCorrect(this, args);
             }
             isValidated = false;
         }
         else
         {
             ErrorCapturedEventArgs args = new ErrorCapturedEventArgs(row, ValidatorType.Field, vs.ErrorType, field.Name, validator.ToString(vs.Description));
             if (ErrorCaptured != null) ErrorCaptured(this, args);
         }
     }
     else
     {
         ErrorCapturedEventArgs args = new ErrorCapturedEventArgs(row, ValidatorType.Field, vs.ErrorType, field.Name, validator.ToString(vs.Description));
         if (ErrorCaptured != null) ErrorCaptured(this, args);
     }
     return isValidated;
 }