internal static ValidationCriterion GetValidationCriterion(GridColumnInfo columnInfo, IControlManager cm)
        {
            ValidationCriterion cri1 = null;

            if (!string.IsNullOrEmpty(columnInfo.ValidRegularExpression))
            {
                cri1 = new MyRegularExpressionCriterion(columnInfo.GridColumnName,
                                                        Xceed.Validation.ValidationLevel.Manual,
                                                        new System.Text.RegularExpressions.Regex(columnInfo.ValidRegularExpression, System.Text.RegularExpressions.RegexOptions.Singleline),
                                                        false, true, new Xceed.Validation.CustomValidationMessages());
                cri1.CustomValidationMessages.RegularExpression = columnInfo.ValidErrorMessage;
            }
            ValidationCriterion cri2 = null;

            if (!string.IsNullOrEmpty(columnInfo.ValidScript))
            {
                cri2 = new ScriptCriterion(columnInfo.GridColumnName,
                                           Xceed.Validation.ValidationLevel.Manual,
                                           columnInfo.ValidScript, new Dictionary <string, object> {
                    { "cm", cm }
                },
                                           false, true, new Xceed.Validation.CustomValidationMessages());
                cri2.CustomValidationMessages.RegularExpression = columnInfo.ValidErrorMessage;
            }

            ValidationCriterion cri3 = null;

            if (Authority.AuthorizeByRule(columnInfo.NotNull))
            {
                cri3 = new RequiredFieldCriterion(columnInfo.GridColumnName,
                                                  Xceed.Validation.ValidationLevel.Manual, GridColumnInfoHelper.CreateType(columnInfo),
                                                  false, true, new Xceed.Validation.CustomValidationMessages());
            }
            var ret = TryAndValidations(TryAndValidations(cri1, cri2), cri3);

            if (ret != null)
            {
                ret.Name = columnInfo.GridColumnName;
            }
            return(ret);
        }
        /// <summary>
        /// 按照Property来默认设置Validation
        /// </summary>
        private void CreatePropertyValidations()
        {
            foreach (Xceed.Grid.Column column in m_grid.Columns)
            {
                if (!column.Visible)
                {
                    continue;
                }

                GridColumnInfo info = column.Tag as GridColumnInfo;
                if (info == null)
                {
                    continue;
                }

                if (string.IsNullOrEmpty(info.Navigator) && !string.IsNullOrEmpty(info.PropertyName))
                {
                    var attribute = m_cm.DisplayManager.EntityInfo.GetPropertMetadata(info.PropertyName);
                    if (attribute != null)
                    {
                        ValidationCriterion cri1 = null;
                        if (attribute.NotNull)
                        {
                            cri1 = new RequiredFieldCriterion(info.GridColumnName, ValidationLevel.Manual, column.DataType, false, true, null);
                        }

                        ValidationCriterion cri2 = null;
                        if (attribute.Length > 0)
                        {
                            cri2 = new MaxLengthFieldCriterion(info.GridColumnName, ValidationLevel.Manual, attribute.Length, false, true, null);
                        }

                        SetGridValidation(column.FieldName, TryAndValidations(cri1, cri2));
                    }
                }
            }
        }
        /// <summary>
        /// ����Property��Ĭ������Validation
        /// </summary>
        private void CreatePropertyValidations()
        {
            foreach (Xceed.Grid.Column column in m_grid.Columns)
            {
                if (!column.Visible)
                {
                    continue;
                }

                GridColumnInfo info = column.Tag as GridColumnInfo;
                if (info == null)
                {
                    continue;
                }

                if (string.IsNullOrEmpty(info.Navigator) && !string.IsNullOrEmpty(info.PropertyName))
                {
                    var attribute = m_cm.DisplayManager.EntityInfo.GetPropertMetadata(info.PropertyName);
                    if (attribute != null)
                    {
                        ValidationCriterion cri1 = null;
                        if (attribute.NotNull)
                        {
                            cri1 = new RequiredFieldCriterion(info.GridColumnName, ValidationLevel.Manual, column.DataType, false, true, null);
                        }

                        ValidationCriterion cri2 = null;
                        if (attribute.Length > 0)
                        {
                            cri2 = new MaxLengthFieldCriterion(info.GridColumnName, ValidationLevel.Manual, attribute.Length, false, true, null);
                        }

                        SetGridValidation(column.FieldName, TryAndValidations(cri1, cri2));
                    }
                }
            }
        }
        internal static ValidationCriterion GetValidationCriterion(GridColumnInfo columnInfo, IControlManager cm)
        {
            ValidationCriterion cri1 = null;
            if (!string.IsNullOrEmpty(columnInfo.ValidRegularExpression))
            {
                cri1 = new MyRegularExpressionCriterion(columnInfo.GridColumnName,
                    Xceed.Validation.ValidationLevel.Manual,
                    new System.Text.RegularExpressions.Regex(columnInfo.ValidRegularExpression, System.Text.RegularExpressions.RegexOptions.Singleline),
                    false, true, new Xceed.Validation.CustomValidationMessages());
                cri1.CustomValidationMessages.RegularExpression = columnInfo.ValidErrorMessage;
            }
            ValidationCriterion cri2 = null;
            if (!string.IsNullOrEmpty(columnInfo.ValidScript))
            {
                cri2 = new ScriptCriterion(columnInfo.GridColumnName,
                    Xceed.Validation.ValidationLevel.Manual,
                    columnInfo.ValidScript, new Dictionary<string, object> { { "cm", cm } },
                    false, true, new Xceed.Validation.CustomValidationMessages());
                cri2.CustomValidationMessages.RegularExpression = columnInfo.ValidErrorMessage;
            }

            ValidationCriterion cri3 = null;
            if (Authority.AuthorizeByRule(columnInfo.NotNull))
            {
                cri3 = new RequiredFieldCriterion(columnInfo.GridColumnName,
                    Xceed.Validation.ValidationLevel.Manual, GridColumnInfoHelper.CreateType(columnInfo),
                    false, true, new Xceed.Validation.CustomValidationMessages());
            }
            var ret = TryAndValidations(TryAndValidations(cri1, cri2), cri3);
            if (ret != null)
            {
                ret.Name = columnInfo.GridColumnName;
            }
            return ret;
        }