コード例 #1
0
        protected override string ChildPropertyValidation(ModifiableEntity sender, System.Reflection.PropertyInfo pi)
        {
            if (sender is ChartScriptColumnEmbedded column && pi.Name == nameof(column.IsGroupKey))
            {
                if (column.IsGroupKey)
                {
                    if (!ChartUtils.Flag(ChartColumnType.Groupable, column.ColumnType))
                    {
                        return("{0} can not be true for {1}".FormatWith(pi.NiceName(), column.ColumnType.NiceToString()));
                    }
                }
            }

            if (sender is ChartScriptParameterEmbedded param && pi.Name == nameof(param.ColumnIndex))
            {
                if (param.ColumnIndex == null && param.ShouldHaveColumnIndex())
                {
                    return(ValidationMessage._0IsNecessary.NiceToString(pi.NiceName()));
                }

                if (param.ColumnIndex.HasValue && !(0 <= param.ColumnIndex && param.ColumnIndex < this.Columns.Count))
                {
                    return(ValidationMessage._0HasToBeBetween1And2.NiceToString(pi.NiceName(), 0, this.Columns.Count));
                }
            }

            return(base.ChildPropertyValidation(sender, pi));
        }
コード例 #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 (!ChartUtils.IsChartColumnType(Token.Token, ScriptColumn.ColumnType))
                {
                    return(ChartMessage._0IsNot1.NiceToString().FormatWith(DisplayName, ScriptColumn.ColumnType));
                }
            }

            return(base.PropertyValidation(pi));
        }
コード例 #3
0
ファイル: ChartColumn.cs プロジェクト: crazyants/extensions
        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));
        }
コード例 #4
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));
        }
コード例 #5
0
ファイル: UserChart.cs プロジェクト: ywscr/extensions
 public void FixParameters(ChartColumnEmbedded chartColumn)
 {
     ChartUtils.FixParameters(this, chartColumn);
 }
コード例 #6
0
 public bool CompatibleWith(QueryToken?token)
 {
     return(TypeFilter == null || token != null && ChartUtils.IsChartColumnType(token, TypeFilter.Value));
 }