Ejemplo n.º 1
0
        protected override string?PropertyValidation(PropertyInfo pi)
        {
            if (pi.Name == nameof(Token))
            {
                if (Token == null)
                {
                    return(!scriptColumn.IsOptional ? ChartMessage._0IsNotOptional.NiceToString().FormatWith(scriptColumn.DisplayName) : null);
                }

                if (!ChartUtils.IsChartColumnType(Token.Token, ScriptColumn.ColumnType))
                {
                    return(ChartMessage._0IsNot1.NiceToString().FormatWith(DisplayName, ScriptColumn.ColumnType));
                }
            }

            return(base.PropertyValidation(pi));
        }
Ejemplo n.º 2
0
        protected override string PropertyValidation(PropertyInfo pi)
        {
            if (pi.Name == nameof(Token))
            {
                if (Token == null)
                {
                    return(!scriptColumn.IsOptional ? ChartMessage._0IsNotOptional.NiceToString().FormatWith(scriptColumn.DisplayName) : null);
                }

                if (parentChart.GroupResults)
                {
                    if (scriptColumn.IsGroupKey)
                    {
                        if (Token.Token is AggregateToken)
                        {
                            return(ChartMessage._0IsKeyBut1IsAnAggregate.NiceToString().FormatWith(scriptColumn.DisplayName, DisplayName));
                        }
                    }
                    else
                    {
                        if (!(Token.Token is AggregateToken))
                        {
                            return(ChartMessage._0ShouldBeAnAggregate.NiceToString().FormatWith(scriptColumn.DisplayName, DisplayName));
                        }
                    }
                }
                else
                {
                    if (Token.Token is AggregateToken)
                    {
                        return(ChartMessage._0IsAnAggregateButTheChartIsNotGrouping.NiceToString().FormatWith(DisplayName));
                    }
                }

                if (!ChartUtils.IsChartColumnType(token.Token, ScriptColumn.ColumnType))
                {
                    return(ChartMessage._0IsNot1.NiceToString().FormatWith(DisplayName, ScriptColumn.ColumnType));
                }
            }

            return(base.PropertyValidation(pi));
        }
Ejemplo n.º 3
0
        public bool IsCompatibleWith(IChartBase chartBase)
        {
            if (GroupBy == GroupByChart.Always && !chartBase.GroupResults)
            {
                return(false);
            }

            if (GroupBy == GroupByChart.Never && chartBase.GroupResults)
            {
                return(false);
            }

            return(Columns.ZipOrDefault(chartBase.Columns, (s, c) =>
            {
                if (s == null)
                {
                    return c.Token == null;
                }

                if (c == null || c.Token == null)
                {
                    return s.IsOptional;
                }

                if (!ChartUtils.IsChartColumnType(c.Token.Token, s.ColumnType))
                {
                    return false;
                }

                if (c.Token.Token is AggregateToken)
                {
                    return !s.IsGroupKey;
                }
                else
                {
                    return s.IsGroupKey || !chartBase.GroupResults;
                }
            }).All(a => a));
        }
Ejemplo n.º 4
0
 public bool CompatibleWith(QueryToken?token)
 {
     return(TypeFilter == null || token != null && ChartUtils.IsChartColumnType(token, TypeFilter.Value));
 }