Exemple #1
0
        protected override string PropertyValidation(System.Reflection.PropertyInfo pi)
        {
            if (pi.Name == nameof(GroupBy))
            {
                if (GroupBy == GroupByChart.Always || GroupBy == GroupByChart.Optional)
                {
                    if (!Columns.Any(a => a.IsGroupKey))
                    {
                        return("{0} {1} requires some key columns".FormatWith(pi.NiceName(), GroupBy.NiceToString()));
                    }
                }
                else
                {
                    if (Columns.Any(a => a.IsGroupKey))
                    {
                        return("{0} {1} should not have key".FormatWith(pi.NiceName(), GroupBy.NiceToString()));
                    }
                }
            }

            if (pi.Name == nameof(Script))
            {
                if (!Regex.IsMatch(Script, @"function\s+DrawChart\s*\(\s*chart\s*,\s*data\s*\)", RegexOptions.Singleline))
                {
                    return("{0} should be a definition of function DrawChart(chart, data)".FormatWith(pi.NiceName()));
                }
            }

            return(base.PropertyValidation(pi));
        }