Esempio n. 1
0
        public WDBField AddField(int col, string name, string desc, string type, string platform, string defaultValue, string validationRule)
        {
            WDBField field = WDBUtility.CreateField(col, name, desc, type, platform, defaultValue, validationRule);

            fields.Add(field);

            return(field);
        }
Esempio n. 2
0
        public WDBCellValidation[] GetValidations()
        {
            List <WDBCellValidation> result = new List <WDBCellValidation>();

            List <string> rules = new List <string>();
            var           defaultValidations = GetTypeDefaultValidations();

            if (defaultValidations != null && defaultValidations.Length > 0)
            {
                rules.AddRange(defaultValidations);
            }
            if (!string.IsNullOrEmpty(Validation))
            {
                var customValidations = (from rule in Validation.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries)
                                         select rule.Trim()).ToArray();
                if (customValidations != null && customValidations.Length > 0)
                {
                    rules.AddRange(customValidations);
                }
            }

            if (rules.Count > 0)
            {
                foreach (var rule in rules)
                {
                    if (WDBUtility.ParserValidationRule(rule, out var name, out var values))
                    {
                        WDBCellValidation validation = WDBCellValidationFactory.CreateValidation(name);
                        if (validation != null)
                        {
                            validation.SetRule(values);
                            result.Add(validation);
                        }
                        else
                        {
                            throw new WDBValidationNotFoundException(Column, rule);
                        }
                    }
                    else
                    {
                        throw new WDBValidationParserException(Column, rule);
                    }
                }